From 14729c89f55c3fee07b081d4ba4d4441756a52ce Mon Sep 17 00:00:00 2001 From: Guillaume Date: Thu, 25 Jul 2024 14:33:06 +0200 Subject: [PATCH] :arrow_up: Support `psr/log` 2 and 3 --- .gitignore | 3 ++- composer.json | 4 ++-- src/Mouf/Utils/Log/Psr/MultiLogger.php | 21 ++++++--------------- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index b25c15b..d1502b0 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -*~ +vendor/ +composer.lock diff --git a/composer.json b/composer.json index 8a02366..331a9bd 100644 --- a/composer.json +++ b/composer.json @@ -13,8 +13,8 @@ } ], "require": { - "php": ">=5.3.0", - "psr/log" : "~1.0" + "php": "^8.0", + "psr/log": "^2.0 || ^3.0" }, "autoload": { "psr-0": { diff --git a/src/Mouf/Utils/Log/Psr/MultiLogger.php b/src/Mouf/Utils/Log/Psr/MultiLogger.php index 110fed6..fc41bdf 100644 --- a/src/Mouf/Utils/Log/Psr/MultiLogger.php +++ b/src/Mouf/Utils/Log/Psr/MultiLogger.php @@ -16,40 +16,31 @@ */ class MultiLogger extends AbstractLogger { - /** - * @var LoggerInterface[] - */ - private $loggers; + /** @var LoggerInterface[] */ + private array $loggers; /** * @param LoggerInterface[] $loggers Array of loggers to be called */ - public function __construct(array $loggers = array()) + public function __construct(array $loggers = []) { $this->loggers = $loggers; } /** * Adds a logger to the list of loggers. - * - * @param LoggerInterface $logger */ - public function addLogger(LoggerInterface $logger) + public function addLogger(LoggerInterface $logger): void { $this->loggers[] = $logger; } /** - * Logs with an arbitrary level. - * - * @param mixed $level - * @param string $message - * @param array $context + * {@inheritdoc} */ - public function log($level, $message, array $context = array()) + public function log($level, string|\Stringable $message, array $context = []): void { foreach ($this->loggers as $logger) { - /* @var $logger LoggerInterface */ $logger->log($level, $message, $context); } }