From 0cfb72c6b5bbb581743e67644d591144ec9a6e3f Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 4 Jul 2017 19:02:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0record=5Ftrace=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=8F=82=E6=95=B0=E7=94=A8=E4=BA=8E=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E8=AE=B0=E5=BD=95trace=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- convention.php | 2 ++ library/think/exception/Handle.php | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/convention.php b/convention.php index 4bde7d88..4ca03c06 100644 --- a/convention.php +++ b/convention.php @@ -155,6 +155,8 @@ return [ 'show_error_msg' => false, // 异常处理handle类 留空使用 \think\exception\Handle 'exception_handle' => '', + // 是否记录trace信息到日志 + 'record_trace' => false, // +---------------------------------------------------------------------- // | 日志设置 diff --git a/library/think/exception/Handle.php b/library/think/exception/Handle.php index 8b6e6c40..d975690e 100644 --- a/library/think/exception/Handle.php +++ b/library/think/exception/Handle.php @@ -52,6 +52,10 @@ class Handle $log = "[{$data['code']}]{$data['message']}"; } + if (Config::get('record_trace')) { + $log .= "\r\n" . $exception->getTraceAsString(); + } + Log::record($log, 'error'); } }