mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-14 15:35:31 +00:00
MainLogger: implement BufferedLogger
This commit is contained in:
parent
64d5320ac9
commit
f5cd87ac95
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user