123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace huolib\tool;
- class Log {
-
- public static function getBacktrace() {
- ob_start();
- debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
- return ob_get_clean();
- }
-
- public static function outErrorLog($debug_param, $result = [], $step = 0, $other = [], $type = \think\Log::ERROR) {
- $_request_param = request()->param();
- if (!empty($_request_param)) {
- \think\Log::record('[ REQUEST ] '.var_export(request()->param(), true), $type);
- }
- $_args = get_val($debug_param, 'args', []);
- if (!empty($_args)) {
- \think\Log::record('[ ARGS ] '.var_export($_args, true), $type);
- }
- if (!empty($result)) {
- \think\Log::record('[ RESULT ] '.var_export($result, true), $type);
- }
- \think\Log::record('[ TRACE ] '.var_export(self::getBacktrace(), true), $type);
- if (!empty($step)) {
- \think\Log::record('[ STEP ] '.var_export($step, true), $type);
- }
- if (!empty($other)) {
- \think\Log::record('[ OTHER ] '.var_export($other, true), $type);
- }
- return \think\Log::save();
- }
- }
|