1 | <?php |
||
20 | class Log extends AbstractLogger implements LoggerInterface |
||
21 | { |
||
22 | /** |
||
23 | * Priorities |
||
24 | */ |
||
25 | const PRIORITIES = [ |
||
26 | LogLevel::EMERGENCY => 0, |
||
27 | LogLevel::ALERT => 1, |
||
28 | LogLevel::CRITICAL => 2, |
||
29 | LogLevel::ERROR => 3, |
||
30 | LogLevel::WARNING => 4, |
||
31 | LogLevel::NOTICE => 5, |
||
32 | LogLevel::INFO => 6, |
||
33 | LogLevel::DEBUG => 7, |
||
34 | ]; |
||
35 | |||
36 | |||
37 | /** |
||
38 | * Adapters |
||
39 | * |
||
40 | * @var array |
||
41 | */ |
||
42 | protected $adapter = []; |
||
43 | |||
44 | |||
45 | /** |
||
46 | * static context |
||
47 | * |
||
48 | * @var array |
||
49 | */ |
||
50 | protected $context = []; |
||
51 | |||
52 | |||
53 | /** |
||
54 | * Initialize logger |
||
55 | * |
||
56 | * @param Iterable $config |
||
57 | * @return void |
||
|
|||
58 | */ |
||
59 | public function __construct(?Iterable $config=null) |
||
63 | |||
64 | |||
65 | /** |
||
66 | * Set options |
||
67 | * |
||
68 | * @param Iterable $config |
||
69 | * @return Logger |
||
70 | */ |
||
71 | public function setOptions(?Iterable $config=null) |
||
85 | |||
86 | |||
87 | /** |
||
88 | * Add datatype |
||
89 | * |
||
90 | * @param string $name |
||
91 | * @param string $class |
||
92 | * @param Iterable $config |
||
93 | * @return AdapterInterface |
||
94 | */ |
||
95 | public function addAdapter(string $name, string $class, ?Iterable $config=null): AdapterInterface |
||
108 | |||
109 | |||
110 | /** |
||
111 | * Get adapter |
||
112 | * |
||
113 | * @param string $name |
||
114 | * @return AdapterInterface |
||
115 | */ |
||
116 | public function getAdapter(string $name): AdapterInterface |
||
124 | |||
125 | |||
126 | /** |
||
127 | * Get adapters |
||
128 | * |
||
129 | * @param array $adapters |
||
130 | * @return array |
||
131 | */ |
||
132 | public function getAdapters(array $adapters=[]): array |
||
148 | |||
149 | |||
150 | |||
151 | /** |
||
152 | * Log message |
||
153 | * |
||
154 | * @param string $level |
||
155 | * @param string $message |
||
156 | * @param array $context |
||
157 | * @return bool |
||
158 | */ |
||
159 | public function log($level, $message, array $context=[]): bool |
||
176 | |||
177 | |||
178 | /** |
||
179 | * Add static context |
||
180 | * |
||
181 | * @param string $name |
||
182 | * @param string $value |
||
183 | * @return Logger |
||
184 | */ |
||
185 | public function addContext(string $name, string $value): Logger |
||
190 | |||
191 | |||
192 | /** |
||
193 | * Log message |
||
194 | * |
||
195 | * @param string $message |
||
196 | * @param string $format |
||
197 | * @param string $date_format |
||
198 | * @param string $level |
||
199 | * @param array $context |
||
200 | * @return void |
||
201 | */ |
||
202 | protected function _format(string $message, string $format, string $date_format, string $level, array $context=[]): string |
||
253 | } |
||
254 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.