Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
LoggerFactory | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
createLogger | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace PeServer\Core\Log; |
6 | |
7 | use PeServer\Core\DI\DiContainer; |
8 | use PeServer\Core\DI\DiFactoryBase; |
9 | use PeServer\Core\DI\DiFactoryTrait; |
10 | use PeServer\Core\DI\IDiContainer; |
11 | use PeServer\Core\Environment; |
12 | use PeServer\Core\Log\ILogger; |
13 | use PeServer\Core\Log\ILoggerFactory; |
14 | use PeServer\Core\Log\ILogProvider; |
15 | use PeServer\Core\Log\Logging; |
16 | use PeServer\Core\Log\LogOptions; |
17 | use PeServer\Core\Log\MultiLogger; |
18 | use PeServer\Core\Log\NullLogger; |
19 | use PeServer\Core\Log\XdebugLogger; |
20 | use PeServer\Core\Text; |
21 | use PeServer\Core\Throws\ArgumentException; |
22 | use PeServer\Core\Throws\NotImplementedException; |
23 | use PeServer\Core\TypeUtility; |
24 | |
25 | class LoggerFactory extends DiFactoryBase implements ILoggerFactory |
26 | { |
27 | use DiFactoryTrait; |
28 | |
29 | #region ILoggerFactory |
30 | |
31 | public function createLogger(string|object $header, int $baseTraceIndex = 0): ILogger |
32 | { |
33 | /** @var ILogProvider */ |
34 | $logProvider = $this->container->get(ILogProvider::class); |
35 | |
36 | $useHeader = Logging::toHeader($header); |
37 | $loggers = $logProvider->create($useHeader, $baseTraceIndex); |
38 | |
39 | // $debugLogger = $this->createXdebugLogger($useHeader, $baseTraceIndex); |
40 | |
41 | // if (empty($loggers)) { |
42 | // if ($debugLogger === null) { |
43 | // return new NullLogger(); |
44 | // } |
45 | // return $debugLogger; |
46 | // } |
47 | |
48 | // if ($debugLogger !== null) { |
49 | // $loggers[] = $debugLogger; |
50 | // } |
51 | |
52 | return new MultiLogger($baseTraceIndex, $loggers); |
53 | } |
54 | |
55 | #endregion |
56 | } |