improve remote terminal logging

This commit is contained in:
sunxyw
2022-05-23 11:44:21 +08:00
parent fa6af88566
commit 782e668abf
3 changed files with 50 additions and 36 deletions

View File

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