* @version : HUOUNION 8.5 */ namespace huolib\tool; class Log { /** * 生成调用栈 * * @return false|string */ public static function getBacktrace() { ob_start(); debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); return ob_get_clean(); } /** * 输出错误日志 * * @param array $debug_param * @param array $result * @param int $step * @param array $other * @param string $type * * @return bool */ 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(); } }