1 | <?php |
||
19 | class Logger extends File implements LoggerInterface |
||
20 | { |
||
21 | |||
22 | /** Log files */ |
||
23 | protected $_logFiles = array( |
||
24 | "default" => "system.log", |
||
25 | ); |
||
26 | protected $_defaultPath = '/var/logs'; |
||
27 | |||
28 | /** |
||
29 | * Constructor |
||
30 | * |
||
31 | * @param array $logFiles |
||
32 | * @param string $logDir fully qualified path or a path relative to the erdiko root |
||
33 | */ |
||
34 | public function __construct($logFiles = array(), $logDir = null) |
||
52 | |||
53 | /** |
||
54 | * Log |
||
55 | * |
||
56 | * @param string $level |
||
57 | * @param string or an object with a __toString() method$ message |
||
58 | * @param array $context |
||
59 | * @return bool |
||
60 | */ |
||
61 | public function log($level, $message, array $context = array()) |
||
88 | |||
89 | /** |
||
90 | * Add Record |
||
91 | * |
||
92 | * @param string $level |
||
93 | * @param string or an object with a __toString() method$ message |
||
94 | * @param array $context |
||
95 | * @return bool |
||
96 | */ |
||
97 | public function addRecord($level, $message, array $context = array()) |
||
105 | |||
106 | /** |
||
107 | * Implementation of Placeholder Interpolation |
||
108 | * The message MAY contain placeholders which implementors MAY replace with values from the context array. |
||
109 | * Placeholder names MUST correspond to keys in the context array. |
||
110 | * |
||
111 | * @param string $message or an object with a __toString() method |
||
112 | * @param array $context replacement values for placeholders |
||
113 | * @return bool |
||
114 | */ |
||
115 | function interpolate($message, array $context = array()) |
||
130 | |||
131 | /** |
||
132 | * Add log file |
||
133 | * Valid if multiple log files exist |
||
134 | * |
||
135 | * @param mixed $key |
||
136 | * @param string $logFileName |
||
137 | * @return bool |
||
138 | */ |
||
139 | public function addLogFile($key, $logFileName) |
||
144 | |||
145 | /** |
||
146 | * Remove log file |
||
147 | * Valid if multiple log files exist |
||
148 | * |
||
149 | * @param mixed $key |
||
150 | */ |
||
151 | public function removeLogFile($key) |
||
157 | |||
158 | /** |
||
159 | * Clear Log |
||
160 | * |
||
161 | * @param string $logKey |
||
162 | * @return bool |
||
163 | */ |
||
164 | public function clearLog($logKey = null) |
||
181 | |||
182 | /** Destructor */ |
||
183 | public function __destruct() |
||
186 | |||
187 | /** |
||
188 | * System is unusable. |
||
189 | * |
||
190 | * @param string $message |
||
191 | * @param array $context |
||
192 | * |
||
193 | * @return null |
||
194 | */ |
||
195 | public function emergency($message, array $context = array()) |
||
200 | |||
201 | /** |
||
202 | * Action must be taken immediately. |
||
203 | * |
||
204 | * Example: Entire website down, database unavailable, etc. This should |
||
205 | * trigger the SMS alerts and wake you up. |
||
206 | * |
||
207 | * @param string $message |
||
208 | * @param array $context |
||
209 | * |
||
210 | * @return null |
||
211 | */ |
||
212 | public function alert($message, array $context = array()) |
||
217 | |||
218 | /** |
||
219 | * Critical conditions. |
||
220 | * |
||
221 | * Example: Application component unavailable, unexpected exception. |
||
222 | * |
||
223 | * @param string $message |
||
224 | * @param array $context |
||
225 | * |
||
226 | * @return null |
||
227 | */ |
||
228 | public function critical($message, array $context = array()) |
||
233 | |||
234 | /** |
||
235 | * Runtime errors that do not require immediate action but should typically |
||
236 | * be logged and monitored. |
||
237 | * |
||
238 | * @param string $message |
||
239 | * @param array $context |
||
240 | * |
||
241 | * @return null |
||
242 | */ |
||
243 | public function error($message, array $context = array()) |
||
248 | |||
249 | /** |
||
250 | * Exceptional occurrences that are not errors. |
||
251 | * |
||
252 | * Example: Use of deprecated APIs, poor use of an API, undesirable things |
||
253 | * that are not necessarily wrong. |
||
254 | * |
||
255 | * @param string $message |
||
256 | * @param array $context |
||
257 | * |
||
258 | * @return null |
||
259 | */ |
||
260 | public function warning($message, array $context = array()) |
||
265 | |||
266 | /** |
||
267 | * Normal but significant events. |
||
268 | * |
||
269 | * @param string $message |
||
270 | * @param array $context |
||
271 | * |
||
272 | * @return null |
||
273 | */ |
||
274 | public function notice($message, array $context = array()) |
||
279 | |||
280 | /** |
||
281 | * Interesting events. |
||
282 | * |
||
283 | * Example: User logs in, SQL logs. |
||
284 | * |
||
285 | * @param string $message |
||
286 | * @param array $context |
||
287 | * |
||
288 | * @return null |
||
289 | */ |
||
290 | public function info($message, array $context = array()) |
||
295 | |||
296 | /** |
||
297 | * Detailed debug information. |
||
298 | * |
||
299 | * @param string $message |
||
300 | * @param array $context |
||
301 | * |
||
302 | * @return null |
||
303 | */ |
||
304 | public function debug($message, array $context = array()) |
||
309 | } |
||
310 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.