1 | <?php |
||
35 | class DummyLogger implements LoggerInterface |
||
36 | { |
||
37 | |||
38 | /** |
||
39 | * The channel name we log to. |
||
40 | * |
||
41 | * @var string |
||
42 | */ |
||
43 | protected $channelName; |
||
44 | |||
45 | /** |
||
46 | * Array with the handlers. |
||
47 | * |
||
48 | * @var array |
||
49 | */ |
||
50 | protected $handlers; |
||
51 | |||
52 | /** |
||
53 | * Array with the processors. |
||
54 | * |
||
55 | * @var array |
||
56 | */ |
||
57 | protected $processors; |
||
58 | |||
59 | /** |
||
60 | * The log level we want to use. |
||
61 | * |
||
62 | * @var integer |
||
63 | */ |
||
64 | protected $logLevel; |
||
65 | |||
66 | /** |
||
67 | * The available log levels. |
||
68 | * |
||
69 | * @var array |
||
70 | */ |
||
71 | protected $logLevels = array( |
||
72 | LogLevel::DEBUG => 100, // Detailed debug information. |
||
73 | LogLevel::INFO => 200, // Interesting events. Examples: User logs in, SQL logs. |
||
74 | LogLevel::NOTICE => 250, // Normal but significant events. |
||
75 | LogLevel::WARNING => 300, // Exceptional occurrences that are not errors. Examples: Use of deprecated APIs, poor use of an API, undesirable things that are not necessarily wrong. |
||
76 | LogLevel::ERROR => 400, // Runtime errors that do not require immediate action but should typically be logged and monitored. |
||
77 | LogLevel::CRITICAL => 500, // Critical conditions. Example: Application component unavailable, unexpected exception. |
||
78 | LogLevel::ALERT => 550, // Action must be taken immediately. Example: Entire website down, database unavailable, etc. This should trigger the SMS alerts and wake you up. |
||
79 | LogLevel::EMERGENCY => 600, // Emergency: system is unusable. |
||
80 | ); |
||
81 | |||
82 | /** |
||
83 | * Initializes the logger instance with the log level. |
||
84 | * |
||
85 | * @param string $channelName The channel name |
||
86 | * @param array $handlers The array with the handlers |
||
87 | * @param array $processors The array with the processors |
||
88 | * @param integer $logLevel The log level we want to use |
||
89 | */ |
||
90 | public function __construct($channelName, array $handlers = array(), array $processors = array(), $logLevel = LogLevel::INFO) |
||
97 | |||
98 | /** |
||
99 | * System is unusable. |
||
100 | * |
||
101 | * @param string $message The message to log |
||
102 | * @param array $context The context for log |
||
103 | * |
||
104 | * @return null |
||
105 | */ |
||
106 | public function emergency($message, array $context = array()) |
||
110 | |||
111 | /** |
||
112 | * Action must be taken immediately. |
||
113 | * |
||
114 | * Example: Entire website down, database unavailable, etc. This should |
||
115 | * trigger the SMS alerts and wake you up. |
||
116 | * |
||
117 | * @param string $message The message to log |
||
118 | * @param array $context The context for log |
||
119 | * |
||
120 | * @return null |
||
121 | */ |
||
122 | public function alert($message, array $context = array()) |
||
126 | |||
127 | /** |
||
128 | * Critical conditions. |
||
129 | * |
||
130 | * Example: Application component unavailable, unexpected exception. |
||
131 | * |
||
132 | * @param string $message The message to log |
||
133 | * @param array $context The context for log |
||
134 | * |
||
135 | * @return null |
||
136 | */ |
||
137 | public function critical($message, array $context = array()) |
||
141 | |||
142 | /** |
||
143 | * Runtime errors that do not require immediate action but should typically |
||
144 | * be logged and monitored. |
||
145 | * |
||
146 | * @param string $message The message to log |
||
147 | * @param array $context The context for log |
||
148 | * |
||
149 | * @return null |
||
150 | */ |
||
151 | public function error($message, array $context = array()) |
||
155 | |||
156 | /** |
||
157 | * Exceptional occurrences that are not errors. |
||
158 | * |
||
159 | * Example: Use of deprecated APIs, poor use of an API, undesirable things |
||
160 | * that are not necessarily wrong. |
||
161 | * |
||
162 | * @param string $message The message to log |
||
163 | * @param array $context The context for log |
||
164 | * |
||
165 | * @return null |
||
166 | */ |
||
167 | public function warning($message, array $context = array()) |
||
171 | |||
172 | /** |
||
173 | * Normal but significant events. |
||
174 | * |
||
175 | * @param string $message The message to log |
||
176 | * @param array $context The context for log |
||
177 | * |
||
178 | * @return null |
||
179 | */ |
||
180 | public function notice($message, array $context = array()) |
||
184 | |||
185 | /** |
||
186 | * Interesting events. |
||
187 | * |
||
188 | * Example: User logs in, SQL logs. |
||
189 | * |
||
190 | * @param string $message The message to log |
||
191 | * @param array $context The context for log |
||
192 | * |
||
193 | * @return null |
||
194 | */ |
||
195 | public function info($message, array $context = array()) |
||
199 | |||
200 | /** |
||
201 | * Detailed debug information. |
||
202 | * |
||
203 | * @param string $message The message to log |
||
204 | * @param array $context The context for log |
||
205 | * |
||
206 | * @return null |
||
207 | */ |
||
208 | public function debug($message, array $context = array()) |
||
212 | |||
213 | /** |
||
214 | * Logs with an arbitrary level. |
||
215 | * |
||
216 | * @param mixed $level The log level |
||
217 | * @param string $message The message to log |
||
218 | * @param array $context The context for log |
||
219 | * |
||
220 | * @return null |
||
221 | */ |
||
222 | public function log($level, $message, array $context = array()) |
||
226 | |||
227 | /** |
||
228 | * Returns the log level we want to use. |
||
229 | * |
||
230 | * @return integer The log level |
||
231 | */ |
||
232 | protected function getLogLevel() |
||
236 | |||
237 | /** |
||
238 | * Checks if the message should be logged, depending on the log level. |
||
239 | * |
||
240 | * @param string $logLevel The log level to match against |
||
241 | * |
||
242 | * @return boolean TRUE if the message should be logged, else FALSE |
||
243 | */ |
||
244 | protected function shouldLog($logLevel) |
||
248 | } |
||
249 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: