123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- /**
- * Log.php UTF-8
- * 火树错误Log处理
- *
- * @date : 2020/1/11 15:08
- *
- * @license 这不是一个自由软件,未经授权不许任何使用和传播。
- * @author : wuyonghong <wyh@huosdk.com>
- * @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();
- }
- }
|