Total Complexity | 3 |
Total Lines | 35 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | class TerminalLogger extends AbstractLogger |
||
11 | { |
||
12 | /** |
||
13 | * @param string $level |
||
14 | * @param string $message |
||
15 | * @param mixed[] $context |
||
16 | */ |
||
17 | public function log($level, $message, array $context = []): void |
||
18 | { |
||
19 | $logValue = $this->logValue($level); |
||
20 | $streamName = 'stdout'; |
||
21 | if ($logValue > 3) { // greater than warning |
||
22 | $streamName = 'stderr'; |
||
23 | } |
||
24 | file_put_contents( |
||
25 | 'php://' . $streamName, |
||
26 | date('Y-m-d H:i:s') . ' ' . $level . ': ' . $message . PHP_EOL, |
||
27 | FILE_APPEND |
||
28 | ); |
||
29 | } |
||
30 | |||
31 | public function logValue(string $level): int |
||
45 | } |
||
46 | } |
||
47 |