From 475066c9f5628abf1504205ebb0fddb63c66c4ef Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 6 Aug 2017 08:55:46 +0100 Subject: [PATCH] Removed minor code duplication in MainLogger --- src/pocketmine/utils/MainLogger.php | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/pocketmine/utils/MainLogger.php b/src/pocketmine/utils/MainLogger.php index eb92bde8d..018e4701b 100644 --- a/src/pocketmine/utils/MainLogger.php +++ b/src/pocketmine/utils/MainLogger.php @@ -221,6 +221,13 @@ class MainLogger extends \AttachableThreadedLogger{ } } + private function writeLogStream(){ + while($this->logStream->count() > 0){ + $chunk = $this->logStream->shift(); + fwrite($this->logResource, $chunk); + } + } + public function run(){ $this->shutdown = false; $this->logResource = fopen($this->logFile, "a+b"); @@ -230,21 +237,12 @@ class MainLogger extends \AttachableThreadedLogger{ while($this->shutdown === false){ $this->synchronized(function(){ - while($this->logStream->count() > 0){ - $chunk = $this->logStream->shift(); - fwrite($this->logResource, $chunk); - } - + $this->writeLogStream(); $this->wait(25000); }); } - if($this->logStream->count() > 0){ - while($this->logStream->count() > 0){ - $chunk = $this->logStream->shift(); - fwrite($this->logResource, $chunk); - } - } + $this->writeLogStream(); fclose($this->logResource); }