From decb85b493908f246d01da9563707914e74d205c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Thu, 22 Jul 2021 16:04:47 +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, 6 insertions(+), 5 deletions(-) diff --git a/System/Error/Logger.php b/System/Error/Logger.php index 85a5d5a3..f688c163 100644 --- a/System/Error/Logger.php +++ b/System/Error/Logger.php @@ -168,12 +168,13 @@ class Logger extends Component $fileName = storage('server-' . $to_day . '.log', $dirName = 'log/' . ($method ?? 'app')); if (!isset($this->sources[$to_day][$fileName]) || !is_writable($this->sources[$to_day][$fileName])) { - if (!($this->sources[$to_day][$fileName] = fopen($fileName, 'rw'))) { - return; - } + $this->sources[$to_day][$fileName] = fopen($fileName, 'rw'); + } + try { + fwrite($this->sources[$to_day][$fileName], '[' . date('Y-m-d H:i:s') . ']:' . PHP_EOL . $messages . PHP_EOL); + } catch (Throwable $exception) { + $this->output($exception->getMessage()); } - fwrite($this->sources[$to_day][$fileName], '[' . date('Y-m-d H:i:s') . ']:' . PHP_EOL . $messages . PHP_EOL); - $this->clearHistoryFile($dirName); $this->clearPrevLog($to_day);