mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 08:17:34 +00:00
Remove MainLogger singleton and remaining MainLogger hard-dependencies
This commit is contained in:
parent
a4b50e57a4
commit
44a205b1cc
@ -223,7 +223,6 @@ namespace pocketmine {
|
||||
}
|
||||
|
||||
$logger = new MainLogger(\pocketmine\DATA . "server.log");
|
||||
$logger->registerStatic();
|
||||
\GlobalLogger::set($logger);
|
||||
|
||||
if(extension_loaded("xdebug")){
|
||||
|
@ -24,7 +24,6 @@ declare(strict_types=1);
|
||||
namespace pocketmine\scheduler;
|
||||
|
||||
use pocketmine\thread\Worker;
|
||||
use pocketmine\utils\MainLogger;
|
||||
use function gc_enable;
|
||||
use function ini_set;
|
||||
|
||||
@ -46,9 +45,6 @@ class AsyncWorker extends Worker{
|
||||
|
||||
protected function onRun() : void{
|
||||
\GlobalLogger::set($this->logger);
|
||||
if($this->logger instanceof MainLogger){
|
||||
$this->logger->registerStatic();
|
||||
}
|
||||
|
||||
gc_enable();
|
||||
|
||||
|
@ -48,8 +48,6 @@ class MainLogger extends \AttachableThreadedLogger{
|
||||
protected $shutdown;
|
||||
/** @var bool */
|
||||
protected $logDebug;
|
||||
/** @var MainLogger */
|
||||
public static $logger = null;
|
||||
/** @var bool */
|
||||
private $syncFlush = false;
|
||||
|
||||
@ -70,9 +68,6 @@ class MainLogger extends \AttachableThreadedLogger{
|
||||
*/
|
||||
public function __construct(string $logFile, bool $logDebug = false){
|
||||
parent::__construct();
|
||||
if(static::$logger instanceof MainLogger){
|
||||
throw new \RuntimeException("MainLogger has been already created");
|
||||
}
|
||||
touch($logFile);
|
||||
$this->logFile = $logFile;
|
||||
$this->logDebug = $logDebug;
|
||||
@ -85,33 +80,6 @@ class MainLogger extends \AttachableThreadedLogger{
|
||||
$this->start(PTHREADS_INHERIT_NONE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MainLogger
|
||||
*/
|
||||
public static function getLogger() : MainLogger{
|
||||
return static::$logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether a MainLogger instance is statically registered on this thread.
|
||||
* @return bool
|
||||
*/
|
||||
public static function isRegisteredStatic() : bool{
|
||||
return static::$logger !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assigns the MainLogger instance to the {@link MainLogger#logger} static property.
|
||||
*
|
||||
* WARNING: 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() : void{
|
||||
if(static::$logger === null){
|
||||
static::$logger = $this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current logger format used for console output.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user