1 | <?php |
||
9 | abstract class BasicLogger extends AbstractLogger |
||
10 | { |
||
11 | /** |
||
12 | * The level threshold where to log |
||
13 | * |
||
14 | * @var string |
||
15 | */ |
||
16 | private $level; |
||
17 | 14 | ||
18 | /** |
||
19 | 14 | * Set the log level threshold |
|
20 | 14 | * |
|
21 | 14 | * @param string $level |
|
22 | 1 | * @return BasicLogger |
|
23 | */ |
||
24 | 13 | public function setLevel(string $level):BasicLogger |
|
29 | |||
30 | /** |
||
31 | * Checks the given level |
||
32 | * |
||
33 | * @param string $level |
||
34 | * @throws \Psr\Log\InvalidArgumentException |
||
35 | */ |
||
36 | private static function checkLevel($level) |
||
44 | |||
45 | 13 | /** |
|
46 | * Format the message to log and return a memory stream of it |
||
47 | 13 | * |
|
48 | 13 | * @param integer $level |
|
49 | 13 | * The arbitrary level |
|
50 | 13 | * @param string $message |
|
51 | * The message to log |
||
52 | 13 | * @param array $context |
|
53 | * The context of logging |
||
54 | * |
||
55 | * @return \Generics\Streams\MemoryStream The formatted message |
||
56 | */ |
||
57 | protected function getMessage($level, $message, array $context = array()) : MemoryStream |
||
73 | 11 | ||
74 | 10 | /** |
|
75 | * Must be implemented by concrete logger |
||
76 | * |
||
77 | * @param integer $level |
||
78 | * The arbitrary level |
||
79 | * @param string $message |
||
80 | * The message to log |
||
81 | * @param array $context |
||
82 | * The context of logging |
||
83 | */ |
||
84 | abstract protected function logImpl($level, $message, array $context = array()); |
||
85 | |||
86 | /** |
||
87 | * {@inheritDoc} |
||
88 | * @see \Psr\Log\LoggerInterface::log() |
||
89 | */ |
||
90 | public function log($level, $message, array $context = array()) |
||
96 | |||
97 | protected function levelHasReached($level):bool |
||
120 | } |
||
121 |