From f2083f1eaf1889f7c6b8a533591601e2cf2fdec4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Mon, 12 Jul 2021 11:42:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- System/Error/Logger.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/System/Error/Logger.php b/System/Error/Logger.php index b9b9b4d2..109eb7a1 100644 --- a/System/Error/Logger.php +++ b/System/Error/Logger.php @@ -174,18 +174,13 @@ class Logger extends Component } $to_day = date('Y-m-d'); + if (!isset($this->sources[$to_day])) $this->sources[$to_day] = []; - $dirName = 'log/' . ($method ?? 'app'); - if (!isset($this->sources[$to_day])) { - $this->sources[$to_day] = []; - } - - $fileName = storage('server-' . $to_day . '.log', $dirName); + $fileName = storage('server-' . $to_day . '.log', $dirName = 'log/' . ($method ?? 'app')); if (!isset($this->sources[$to_day][$fileName])) { $this->sources[$to_day][$fileName] = fopen($fileName, 'rw'); } - - fwrite($this->sources[$fileName], '[' . date('Y-m-d H:i:s') . ']:' . PHP_EOL . $messages . PHP_EOL); + fwrite($this->sources[$to_day][$fileName], '[' . date('Y-m-d H:i:s') . ']:' . PHP_EOL . $messages . PHP_EOL); $this->clearHistoryFile($dirName);