From 2853d767c59a2f4d01df5dfea3434ffdc5c21cb1 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 11 Jan 2019 17:20:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E5=91=BD=E4=BB=A4=E8=A1=8C?= =?UTF-8?q?=E7=9A=84=E6=97=A5=E5=BF=97json=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/log/driver/File.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/library/think/log/driver/File.php b/library/think/log/driver/File.php index f2296cfa..24fd1474 100644 --- a/library/think/log/driver/File.php +++ b/library/think/log/driver/File.php @@ -154,19 +154,23 @@ class File $info['timestamp'] = date($this->config['time_format']); foreach ($message as $type => $msg) { - $info[$type] = is_array($msg) ? implode("\r\n", $msg) : $msg; + $msg = is_array($msg) ? implode("\r\n", $msg) : $msg; + if (PHP_SAPI == 'cli') { + $info['msg'] = $msg; + $info['type'] = $type; + error_log($this->parseCliLog($info), 3, $destination); + } else { + $info[$type] = $msg; + } } - if (PHP_SAPI == 'cli') { - $message = $this->parseCliLog($info); - } else { + if (PHP_SAPI != 'cli') { // 添加调试日志 $this->getDebugLog($info, $append, $apart); $message = $this->parseLog($info); + return error_log($message, 3, $destination); } - - return error_log($message, 3, $destination); } /**