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
2 changed files with 8 additions and 4 deletions

View File

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

View File

@@ -243,8 +243,12 @@ class ConsoleLogger extends AbstractLogger
fwrite($this->stream, $output); fwrite($this->stream, $output);
fflush($this->stream); fflush($this->stream);
} else { } else {
// use plain text output if ($level <= 4 && $this->use_stderr) {
echo $output; fwrite(STDERR, $output);
} else {
// use plain text output
echo $output;
}
} }
} }