fix logger constructor

This commit is contained in:
sunxyw
2022-05-31 00:51:26 +08:00
parent 80050f11f2
commit 23a6e56478
3 changed files with 10 additions and 10 deletions

View File

@@ -7,17 +7,17 @@ use Psr\Log\LogLevel;
use ZM\Logger\ConsoleLogger;
return [
'level' => LogLevel::DEBUG,
'logger' => static function (string $title = null): LoggerInterface {
if ($title) {
$title = strtoupper($title);
'level' => LogLevel::INFO,
'logger' => static function (string $prefix = null): LoggerInterface {
if ($prefix) {
$prefix = strtoupper($prefix);
} else {
// 在 Master 中worker_id 将不存在
$title = app()->has('worker_id') ? '#' . app('worker_id') : 'MST';
$prefix = app()->has('worker_id') ? '#' . app('worker_id') : 'MST';
}
$logger = new ConsoleLogger(zm_config('logging.level'));
$logger::$format = "[%date%] [%level%] [{$title}] %body%";
$logger::$format = "[%date%] [%level%] [{$prefix}] %body%";
$logger::$date_format = 'Y-m-d H:i:s';
// 如果你喜欢旧版的日志格式,请取消下行注释
// $logger::$date_format = 'm-d H:i:s';