mirror of
https://github.com/zhamao-robot/zhamao-logger.git
synced 2026-07-07 00:35:37 +08:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1d7427abd8 | ||
|
|
1b7e343493 | ||
|
|
97ee152121 | ||
|
|
11156c65a2 |
@@ -10,7 +10,7 @@ use Psr\Log\LogLevel;
|
||||
|
||||
class ConsoleLogger extends AbstractLogger
|
||||
{
|
||||
public const VERSION = '1.1.0';
|
||||
public const VERSION = '1.1.2';
|
||||
|
||||
/**
|
||||
* 日志输出格式
|
||||
@@ -213,12 +213,14 @@ class ConsoleLogger extends AbstractLogger
|
||||
if (!$this->shouldLog($level)) {
|
||||
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(
|
||||
['%date%', '%level%', '%body%'],
|
||||
[date(self::$date_format), strtoupper(substr(self::$levels[$level], 0, 4)), $message],
|
||||
self::$format
|
||||
);
|
||||
$output = str_replace(array_keys($log_replace), array_values($log_replace), self::$format);
|
||||
$output = $this->interpolate($output, array_merge($this->static_context, $context));
|
||||
|
||||
foreach ($this->log_callbacks as $callback) {
|
||||
|
||||
@@ -237,7 +237,12 @@ class TablePrinter
|
||||
}
|
||||
} else {
|
||||
$size = exec('stty size 2>/dev/null');
|
||||
$size = (int) explode(' ', trim($size))[1];
|
||||
// in case stty is not available
|
||||
if (empty($size)) {
|
||||
$size = 0;
|
||||
} else {
|
||||
$size = (int) explode(' ', trim($size))[1];
|
||||
}
|
||||
}
|
||||
if (empty($size)) {
|
||||
return $this->terminal_size = 79;
|
||||
|
||||
Reference in New Issue
Block a user