mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 10:22:56 +00:00
Register MainLogger on AsyncWorkers to make MainLogger::getLogger() usable in AsyncTasks
Threaded static properties aren't thread-local anymore in pthreads 3.1.7dev
This commit is contained in:
@ -46,7 +46,6 @@ class MainLogger extends \AttachableThreadedLogger{
|
||||
if(static::$logger instanceof MainLogger){
|
||||
throw new \RuntimeException("MainLogger has been already created");
|
||||
}
|
||||
static::$logger = $this;
|
||||
touch($logFile);
|
||||
$this->logFile = $logFile;
|
||||
$this->logDebug = (bool) $logDebug;
|
||||
@ -55,12 +54,24 @@ class MainLogger extends \AttachableThreadedLogger{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MainLogger
|
||||
* @return MainLogger|null
|
||||
*/
|
||||
public static function getLogger(){
|
||||
return static::$logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assigns the MainLogger instance to the {@link MainLogger#logger} static property. Because static properties are
|
||||
* thread-local, this must be called from the body of every Thread if you want the logger to be accessible via
|
||||
* {@link MainLogger#getLogger}.
|
||||
*/
|
||||
public function registerStatic(){
|
||||
if(static::$logger instanceof MainLogger){
|
||||
throw new \RuntimeException("MainLogger has been already registered");
|
||||
}
|
||||
static::$logger = $this;
|
||||
}
|
||||
|
||||
public function emergency($message){
|
||||
$this->send($message, \LogLevel::EMERGENCY, "EMERGENCY", TextFormat::RED);
|
||||
}
|
||||
|
Reference in New Issue
Block a user