Enhance output handling in ConsoleLogger to use STDERR for specific log levels

This commit is contained in:
crazywhalecc 2025-12-16 10:56:09 +08:00
parent b28c0c26d5
commit e75fa01ca5
No known key found for this signature in database
GPG Key ID: 1F4BDD59391F2680
2 changed files with 8 additions and 4 deletions

View File

@ -1,6 +1,6 @@
{
"name": "zhamao/logger",
"description": "Another Console Logger for CLI Applications",
"description": "Another Colorful Console Logger for CLI Applications",
"type": "library",
"license": "Apache-2.0",
"autoload": {
@ -16,7 +16,7 @@
"authors": [
{
"name": "jerry",
"email": "admin@zhamao.me"
"email": "github@cwcc.me"
},
{
"name": "sunxyw",

View File

@ -242,11 +242,15 @@ class ConsoleLogger extends AbstractLogger
if ($this->stream) {
fwrite($this->stream, $output);
fflush($this->stream);
} else {
if ($level <= 4 && $this->use_stderr) {
fwrite(STDERR, $output);
} else {
// use plain text output
echo $output;
}
}
}
/**
* 转换日志等级