diff --git a/src/pocketmine/utils/MainLogger.php b/src/pocketmine/utils/MainLogger.php index b3675da66..4bfedc6d9 100644 --- a/src/pocketmine/utils/MainLogger.php +++ b/src/pocketmine/utils/MainLogger.php @@ -70,6 +70,14 @@ class MainLogger extends \AttachableThreadedLogger{ 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. * diff --git a/src/pocketmine/utils/Utils.php b/src/pocketmine/utils/Utils.php index 342bf58cb..d15a59cd7 100644 --- a/src/pocketmine/utils/Utils.php +++ b/src/pocketmine/utils/Utils.php @@ -545,9 +545,8 @@ class Utils{ } public static function kill($pid) : void{ - global $logger; - if($logger instanceof MainLogger){ - $logger->syncFlushBuffer(); + if(MainLogger::isRegisteredStatic()){ + MainLogger::getLogger()->syncFlushBuffer(); } switch(Utils::getOS()){ case "win":