Fixed not being able to remove logger attachments, closes #1141

This commit is contained in:
Dylan K. Taylor 2017-09-05 20:04:19 +01:00
parent b310959fd1
commit 2215543e39
3 changed files with 13 additions and 3 deletions

View File

@ -123,6 +123,13 @@ namespace pocketmine {
define('pocketmine\PATH', realpath(getcwd()) . DIRECTORY_SEPARATOR); define('pocketmine\PATH', realpath(getcwd()) . DIRECTORY_SEPARATOR);
} }
$requiredSplVer = "0.0.1";
if(!is_file(\pocketmine\PATH . "src/spl/version.php") or version_compare($requiredSplVer, require(\pocketmine\PATH . "src/spl/version.php")) > 0){
echo "[CRITICAL] Incompatible PocketMine-SPL submodule version ($requiredSplVer is required)." . PHP_EOL;
echo "[CRITICAL] Please update your submodules or use provided builds." . PHP_EOL;
exit(1);
}
if(!class_exists("ClassLoader", false)){ if(!class_exists("ClassLoader", false)){
if(!is_file(\pocketmine\PATH . "src/spl/ClassLoader.php")){ if(!is_file(\pocketmine\PATH . "src/spl/ClassLoader.php")){
echo "[CRITICAL] Unable to find the PocketMine-SPL library." . PHP_EOL; echo "[CRITICAL] Unable to find the PocketMine-SPL library." . PHP_EOL;

View File

@ -47,6 +47,7 @@ class MainLogger extends \AttachableThreadedLogger{
* @throws \RuntimeException * @throws \RuntimeException
*/ */
public function __construct(string $logFile, bool $logDebug = false){ public function __construct(string $logFile, bool $logDebug = false){
parent::__construct();
if(static::$logger instanceof MainLogger){ if(static::$logger instanceof MainLogger){
throw new \RuntimeException("MainLogger has been already created"); throw new \RuntimeException("MainLogger has been already created");
} }
@ -214,8 +215,10 @@ class MainLogger extends \AttachableThreadedLogger{
echo $message . PHP_EOL; echo $message . PHP_EOL;
} }
if($this->attachment instanceof \ThreadedLoggerAttachment){ foreach($this->attachments as $attachment){
$this->attachment->call($level, $message); if($attachment instanceof \ThreadedLoggerAttachment){
$attachment->call($level, $message);
}
} }
$this->logStream[] = date("Y-m-d", $now) . " " . $cleanMessage . PHP_EOL; $this->logStream[] = date("Y-m-d", $now) . " " . $cleanMessage . PHP_EOL;

@ -1 +1 @@
Subproject commit a5127b224ec35ef6f54d0eae2a69a02d53842640 Subproject commit c4d4841586a19d95f25cc02b23baa00dbbc0b0d7