Removed minor code duplication in MainLogger

This commit is contained in:
Dylan K. Taylor 2017-08-06 08:55:46 +01:00
parent d5f6966ce3
commit 475066c9f5

View File

@ -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);
}