mirror of
https://github.com/zhamao-robot/zhamao-logger.git
synced 2026-07-02 14:25:40 +08:00
update to 1.0.1 (add windows support)
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.0.0-alpha';
|
public const VERSION = '1.0.1';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 日志输出格式
|
* 日志输出格式
|
||||||
|
|||||||
@@ -221,14 +221,28 @@ class TablePrinter
|
|||||||
public function fetchTerminalSize(): int
|
public function fetchTerminalSize(): int
|
||||||
{
|
{
|
||||||
if (!isset($this->terminal_size)) {
|
if (!isset($this->terminal_size)) {
|
||||||
|
/* @phpstan-ignore-next-line */
|
||||||
if (STDIN === false) {
|
if (STDIN === false) {
|
||||||
return $this->terminal_size = 79;
|
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)) {
|
if (empty($size)) {
|
||||||
return $this->terminal_size = 79;
|
return $this->terminal_size = 79;
|
||||||
}
|
}
|
||||||
return $this->terminal_size = (int) explode(' ', trim($size))[1];
|
return $this->terminal_size = $size;
|
||||||
}
|
}
|
||||||
return $this->terminal_size;
|
return $this->terminal_size;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user