-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLogger.php
42 lines (36 loc) · 988 Bytes
/
Logger.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
/**
* Qubus\Log
*
* @link https://github.com/QubusPHP/log
* @copyright 2020
* @author Joshua Parker <[email protected]>
* @license https://opensource.org/licenses/mit-license.php MIT License
*/
declare(strict_types=1);
namespace Qubus\Log;
use Iterator;
use Psr\Log\AbstractLogger;
use Psr\Log\LogLevel;
use Qubus\Log\Loggers\BaseLogger;
use Stringable;
class Logger extends AbstractLogger
{
public function __construct(protected Iterator $loggers)
{
}
/**
* @param string|LogLevel $level
* @param string|Stringable $message
* @param array $context
*/
public function log($level, string|Stringable $message, array $context = []): void
{
foreach ($this->loggers as $logger) {
if (! $logger instanceof BaseLogger && ! $logger->isAvailable($level)) {
continue;
}
$logger->log(level: $level, message: $message, context: $context);
}
}
}