mirror of
https://github.com/zhamao-robot/zhamao-logger.git
synced 2026-07-02 14:25:40 +08:00
Add short level format
This commit is contained in:
@@ -10,7 +10,7 @@ use Psr\Log\LogLevel;
|
|||||||
|
|
||||||
class ConsoleLogger extends AbstractLogger
|
class ConsoleLogger extends AbstractLogger
|
||||||
{
|
{
|
||||||
public const VERSION = '1.1.1';
|
public const VERSION = '1.1.2';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 日志输出格式
|
* 日志输出格式
|
||||||
@@ -213,12 +213,14 @@ class ConsoleLogger extends AbstractLogger
|
|||||||
if (!$this->shouldLog($level)) {
|
if (!$this->shouldLog($level)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
$log_replace = [
|
||||||
|
'%date%' => date(self::$date_format),
|
||||||
|
'%level%' => strtoupper(substr(self::$levels[$level], 0, 4)),
|
||||||
|
'%body%' => $message,
|
||||||
|
'%level_short%' => strtoupper(substr(self::$levels[$level], 0, 1)),
|
||||||
|
];
|
||||||
|
|
||||||
$output = str_replace(
|
$output = str_replace(array_keys($log_replace), array_values($log_replace), self::$format);
|
||||||
['%date%', '%level%', '%body%'],
|
|
||||||
[date(self::$date_format), strtoupper(substr(self::$levels[$level], 0, 4)), $message],
|
|
||||||
self::$format
|
|
||||||
);
|
|
||||||
$output = $this->interpolate($output, array_merge($this->static_context, $context));
|
$output = $this->interpolate($output, array_merge($this->static_context, $context));
|
||||||
|
|
||||||
foreach ($this->log_callbacks as $callback) {
|
foreach ($this->log_callbacks as $callback) {
|
||||||
|
|||||||
Reference in New Issue
Block a user