diff --git a/src/utils/MainLogger.php b/src/utils/MainLogger.php index ab88e2e583..120768cca3 100644 --- a/src/utils/MainLogger.php +++ b/src/utils/MainLogger.php @@ -38,7 +38,7 @@ use function trim; use const PHP_EOL; use const PTHREADS_INHERIT_NONE; -class MainLogger extends \AttachableThreadedLogger{ +class MainLogger extends \AttachableThreadedLogger implements \BufferedLogger{ /** @var string */ protected $logFile; @@ -149,7 +149,7 @@ class MainLogger extends \AttachableThreadedLogger{ $trace = $e->getTrace(); } - $this->synchronized(function() use ($e, $trace) : void{ + $this->buffer(function() use ($e, $trace) : void{ $this->critical(self::printExceptionMessage($e)); foreach(Utils::printableTrace($trace) as $line){ $this->debug($line, true); @@ -210,6 +210,13 @@ class MainLogger extends \AttachableThreadedLogger{ } } + /** + * @phpstan-param \Closure() : void $c + */ + public function buffer(\Closure $c) : void{ + $this->synchronized($c); + } + public function shutdown() : void{ $this->shutdown = true; $this->notify();