zhamao-framework/config/logging.php
2022-05-31 00:51:26 +08:00

27 lines
791 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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