This commit is contained in:
2021-07-22 16:04:47 +08:00
parent 2edeacdd16
commit decb85b493
+5 -4
View File
@@ -168,12 +168,13 @@ class Logger extends Component
$fileName = storage('server-' . $to_day . '.log', $dirName = 'log/' . ($method ?? 'app')); $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 (!isset($this->sources[$to_day][$fileName]) || !is_writable($this->sources[$to_day][$fileName])) {
if (!($this->sources[$to_day][$fileName] = fopen($fileName, 'rw'))) { $this->sources[$to_day][$fileName] = fopen($fileName, 'rw');
return;
}
} }
try {
fwrite($this->sources[$to_day][$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);
} catch (Throwable $exception) {
$this->output($exception->getMessage());
}
$this->clearHistoryFile($dirName); $this->clearHistoryFile($dirName);
$this->clearPrevLog($to_day); $this->clearPrevLog($to_day);