add logging config (#127)

This commit is contained in:
sunxyw
2022-05-16 23:28:02 +08:00
committed by GitHub
parent 87bbffefc3
commit 5cbeee6e86
3 changed files with 34 additions and 1 deletions

21
config/logging.php Normal file
View File

@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;
use ZM\Logger\ConsoleLogger;
return [
'level' => LogLevel::DEBUG,
'logger' => static function (): LoggerInterface {
$worker_id = app('worker_id');
$logger = new ConsoleLogger(zm_config('logging.level'));
$logger::$format = "[%date%] [%level%] [#{$worker_id}] %body%";
$logger::$date_format = 'Y-m-d H:i:s';
// 如果你喜欢旧版的日志格式,请取消下行注释
// $logger::$date_format = 'm-d H:i:s';
return $logger;
},
];