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

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