From 61f709e8cf36bcc24e4efe02acded680a1ce23cd Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 1 Nov 2021 21:42:09 +0000 Subject: [PATCH] Revert "Remove ThreadedLogger, convert AttachableThreadedLogger to trait" This reverts commit 9138a04ab35d9a4d9b85553abb6106e26131862c. --- src/AttachableThreadedLogger.php | 44 +++++++++++++++--- src/AttachableThreadedLoggerTrait.php | 65 --------------------------- src/ThreadedLogger.php | 20 +++++++++ 3 files changed, 59 insertions(+), 70 deletions(-) delete mode 100644 src/AttachableThreadedLoggerTrait.php create mode 100644 src/ThreadedLogger.php diff --git a/src/AttachableThreadedLogger.php b/src/AttachableThreadedLogger.php index 74d63d1..3447216 100644 --- a/src/AttachableThreadedLogger.php +++ b/src/AttachableThreadedLogger.php @@ -15,16 +15,50 @@ * GNU General Public License for more details. */ -interface AttachableThreadedLogger extends \Logger{ +abstract class AttachableThreadedLogger extends \ThreadedLogger{ - public function addAttachment(\ThreadedLoggerAttachment $attachment) : void; + /** @var \Volatile|\ThreadedLoggerAttachment[] */ + protected $attachments; - public function removeAttachment(\ThreadedLoggerAttachment $attachment) : void; + public function __construct(){ + $this->attachments = new \Volatile(); + } - public function removeAttachments() : void; + /** + * @param ThreadedLoggerAttachment $attachment + * + * @return void + */ + public function addAttachment(\ThreadedLoggerAttachment $attachment){ + $this->attachments[] = $attachment; + } + + /** + * @param ThreadedLoggerAttachment $attachment + * + * @return void + */ + public function removeAttachment(\ThreadedLoggerAttachment $attachment){ + foreach($this->attachments as $i => $a){ + if($attachment === $a){ + unset($this->attachments[$i]); + } + } + } + + /** + * @return void + */ + public function removeAttachments(){ + foreach($this->attachments as $i => $a){ + unset($this->attachments[$i]); + } + } /** * @return \ThreadedLoggerAttachment[] */ - public function getAttachments() : array; + public function getAttachments(){ + return (array) $this->attachments; + } } diff --git a/src/AttachableThreadedLoggerTrait.php b/src/AttachableThreadedLoggerTrait.php deleted file mode 100644 index dd57c74..0000000 --- a/src/AttachableThreadedLoggerTrait.php +++ /dev/null @@ -1,65 +0,0 @@ - - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. -*/ - -declare(strict_types=1); - -trait AttachableThreadedLoggerTrait{ - /** @var \Volatile|\ThreadedLoggerAttachment[] */ - protected $attachments; - - public function __construct(){ - $this->attachments = new \Volatile(); - } - - /** - * @param ThreadedLoggerAttachment $attachment - * - * @return void - */ - public function addAttachment(\ThreadedLoggerAttachment $attachment){ - $this->attachments[] = $attachment; - } - - /** - * @param ThreadedLoggerAttachment $attachment - * - * @return void - */ - public function removeAttachment(\ThreadedLoggerAttachment $attachment){ - foreach($this->attachments as $i => $a){ - if($attachment === $a){ - unset($this->attachments[$i]); - } - } - } - - /** - * @return void - */ - public function removeAttachments(){ - foreach($this->attachments as $i => $a){ - unset($this->attachments[$i]); - } - } - - /** - * @return \ThreadedLoggerAttachment[] - */ - public function getAttachments(){ - return (array) $this->attachments; - } -} diff --git a/src/ThreadedLogger.php b/src/ThreadedLogger.php new file mode 100644 index 0000000..889002e --- /dev/null +++ b/src/ThreadedLogger.php @@ -0,0 +1,20 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. +*/ + +abstract class ThreadedLogger extends \Threaded implements Logger{ + +}