mirror of
https://github.com/zhamao-robot/zhamao-logger.git
synced 2026-03-17 20:44:52 +08:00
update to 1.0.1 (add windows support)
This commit is contained in:
parent
af263a9d3b
commit
cc43c4729f
@ -10,7 +10,7 @@ use Psr\Log\LogLevel;
|
||||
|
||||
class ConsoleLogger extends AbstractLogger
|
||||
{
|
||||
public const VERSION = '1.0.0-alpha';
|
||||
public const VERSION = '1.0.1';
|
||||
|
||||
/**
|
||||
* 日志输出格式
|
||||
|
||||
@ -221,14 +221,28 @@ class TablePrinter
|
||||
public function fetchTerminalSize(): int
|
||||
{
|
||||
if (!isset($this->terminal_size)) {
|
||||
/* @phpstan-ignore-next-line */
|
||||
if (STDIN === false) {
|
||||
return $this->terminal_size = 79;
|
||||
}
|
||||
$size = exec('stty size 2>/dev/null');
|
||||
$size = 0;
|
||||
if (DIRECTORY_SEPARATOR === '\\') {
|
||||
exec('mode con', $out);
|
||||
foreach ($out as $v) {
|
||||
if (strpos($v, 'Columns:') !== false) {
|
||||
$num = trim(explode('Columns:', $v)[1]);
|
||||
$size = intval($num);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$size = exec('stty size 2>/dev/null');
|
||||
$size = (int) explode(' ', trim($size))[1];
|
||||
}
|
||||
if (empty($size)) {
|
||||
return $this->terminal_size = 79;
|
||||
}
|
||||
return $this->terminal_size = (int) explode(' ', trim($size))[1];
|
||||
return $this->terminal_size = $size;
|
||||
}
|
||||
return $this->terminal_size;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user