Skip to content

Commit

Permalink
⬆️ Support psr/log 2 and 3
Browse files Browse the repository at this point in the history
  • Loading branch information
homersimpsons committed Jul 25, 2024
1 parent 5af7022 commit 14729c8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*~
vendor/
composer.lock
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
21 changes: 6 additions & 15 deletions src/Mouf/Utils/Log/Psr/MultiLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 14729c8

Please sign in to comment.