fix: remove @ error suppression from echo/fwrite/fflush calls

`@echo` is invalid PHP syntax — echo is a language construct,
not a function, so the @ operator cannot be applied to it. This
causes a parse error on some PHP versions/runtimes.

The recursion guard ($in_log) added in 1.1.7 already prevents
infinite loops when STDOUT/STDERR is broken, so @ suppression
is unnecessary. Remove @ from echo, fwrite, and fflush calls.

Version bumped from 1.1.8 to 1.1.9.
This commit is contained in:
crazywhalecc
2026-06-17 14:58:58 +08:00
committed by Jerry Ma
parent d13c8fb85f
commit 30bee20a0a

View File

@@ -10,7 +10,7 @@ use Psr\Log\LogLevel;
class ConsoleLogger extends AbstractLogger class ConsoleLogger extends AbstractLogger
{ {
public const VERSION = '1.1.8'; public const VERSION = '1.1.9';
/** /**
* 日志输出格式 * 日志输出格式
@@ -258,14 +258,14 @@ class ConsoleLogger extends AbstractLogger
try { try {
// use stream // use stream
if ($this->stream) { if ($this->stream) {
@fwrite($this->stream, $output); fwrite($this->stream, $output);
@fflush($this->stream); fflush($this->stream);
} else { } else {
if ($level <= 4 && $this->use_stderr) { if ($level <= 4 && $this->use_stderr) {
@fwrite(STDERR, $output); fwrite(STDERR, $output);
} else { } else {
// use plain text output // use plain text output
@echo $output; echo $output;
} }
} }
} finally { } finally {