This commit is contained in:
2023-04-11 23:49:01 +08:00
parent e62d83b62b
commit c825fd0d94
+13 -12
View File
@@ -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);
}