From c825fd0d9417ed39caf9caaffef3afe80fec88e8 Mon Sep 17 00:00:00 2001 From: "as2252258@163.com" Date: Tue, 11 Apr 2023 23:49:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kiri-engine/Abstracts/Logger.php | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/kiri-engine/Abstracts/Logger.php b/kiri-engine/Abstracts/Logger.php index 7645b5f5..c0576b4b 100644 --- a/kiri-engine/Abstracts/Logger.php +++ b/kiri-engine/Abstracts/Logger.php @@ -143,19 +143,20 @@ class Logger implements LoggerInterface { // TODO: Implement log() method. $levels = Config::get('log.level', Logger::LOGGER_LEVELS); - if (!in_array($level, $levels) || str_contains($message, 'Event::rshutdown')) { - return; + if (in_array($level, $levels)) { + $_string = '[' . now() . ']' . ucfirst($level) . ': ' . $message . PHP_EOL; + if (!empty($context)) { + $_string .= $this->_string($context); + } + if (str_contains($_string, 'Event::rshutdown')) { + return; + } + file_put_contents('php://output', $_string); + + $filename = storage('log-' . date('Y-m-d') . '.log', 'log/'); + + file_put_contents($filename, $_string, FILE_APPEND); } - - $_string = '[' . now() . ']' . ucfirst($level) . ': ' . $message . PHP_EOL; - if (!empty($context)) { - $_string .= $this->_string($context); - } - file_put_contents('php://output', $_string); - - $filename = storage('log-' . date('Y-m-d') . '.log', 'log/'); - - file_put_contents($filename, $_string, FILE_APPEND); }