4 Commits
1.1.0 ... 1.1.2

Author SHA1 Message Date
crazywhalecc
1d7427abd8 Add short level format 2025-04-24 10:02:28 +08:00
sunxyw
1b7e343493 Merge pull request #7 from zhamao-robot/fix-no-terminal-size-without-io
修復无交互环境下无法获取终端尺寸
2023-03-09 23:41:10 +08:00
sunxyw
97ee152121 update version 2023-03-09 23:40:30 +08:00
sunxyw
11156c65a2 fix no terminal size without io 2023-03-09 22:41:30 +08:00
2 changed files with 14 additions and 7 deletions

View File

@@ -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) {

View File

@@ -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;