1 | <?php |
||
18 | abstract class BasicLogger extends AbstractLogger |
||
19 | { |
||
20 | |||
21 | /** |
||
22 | * The level threshold where to log |
||
23 | * |
||
24 | * @var string |
||
25 | */ |
||
26 | private $level; |
||
27 | |||
28 | /** |
||
29 | * Set the log level threshold |
||
30 | * |
||
31 | * @param string $level |
||
32 | * @return BasicLogger |
||
33 | */ |
||
34 | 1 | public function setLevel(string $level): BasicLogger |
|
39 | |||
40 | /** |
||
41 | * Checks the given level |
||
42 | * |
||
43 | * @param string $level |
||
44 | * @throws \Psr\Log\InvalidArgumentException |
||
45 | */ |
||
46 | 15 | private static function checkLevel($level) |
|
54 | |||
55 | /** |
||
56 | * Format the message to log and return a memory stream of it |
||
57 | * |
||
58 | * @param integer $level |
||
59 | * The arbitrary level |
||
60 | * @param string $message |
||
61 | * The message to log |
||
62 | * @param array $context |
||
63 | * The context of logging |
||
64 | * |
||
65 | * @return \Generics\Streams\MemoryStream The formatted message |
||
66 | */ |
||
67 | 15 | protected function getMessage($level, $message, array $context = array()): MemoryStream |
|
85 | |||
86 | /** |
||
87 | * Must be implemented by concrete logger |
||
88 | * |
||
89 | * @param integer $level |
||
90 | * The arbitrary level |
||
91 | * @param string $message |
||
92 | * The message to log |
||
93 | * @param array $context |
||
94 | * The context of logging |
||
95 | */ |
||
96 | abstract protected function logImpl($level, $message, array $context = array()); |
||
97 | |||
98 | /** |
||
99 | * |
||
100 | * {@inheritdoc} |
||
101 | * @see \Psr\Log\LoggerInterface::log() |
||
102 | */ |
||
103 | 12 | public function log($level, $message, array $context = array()) |
|
109 | |||
110 | 15 | protected function levelHasReached($level): bool |
|
133 | } |
||
134 |