1 | <?php |
||
10 | abstract class Base implements LoggerInterface |
||
11 | { |
||
12 | /** |
||
13 | * @var array |
||
14 | */ |
||
15 | protected $config; |
||
16 | |||
17 | /** |
||
18 | * @var Logger |
||
19 | */ |
||
20 | protected $logger; |
||
21 | |||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | private $title; |
||
26 | |||
27 | /** |
||
28 | * @param array $config An array of config values to overwrite |
||
29 | * @param Logger $logger A Monolog instance to use |
||
30 | * @param string $title The title to set for the handlers |
||
31 | */ |
||
32 | 36 | public function __construct(array $config = [], Logger $logger = null, $title = ""){ |
|
45 | |||
46 | /** |
||
47 | * Returns a list of driver names to load |
||
48 | * @return array An array of drivers to use |
||
49 | */ |
||
50 | abstract protected function getDrivers(); |
||
51 | |||
52 | /** |
||
53 | * Gets a handler instance for the provided name |
||
54 | * @param string $name The name of the driver you want to use |
||
55 | * @return HandlerInterface |
||
56 | */ |
||
57 | 36 | protected function getHandlerInstanceByName($name){ |
|
61 | |||
62 | /** |
||
63 | * Pushes a Monolog Handler in to the Monolog Logger instance |
||
64 | * @param HandlerInterface $handler The Handler to attach |
||
65 | * @return void |
||
66 | */ |
||
67 | 36 | protected function attachHandler(HandlerInterface $handler){ |
|
70 | |||
71 | /** |
||
72 | * This will attach all the monolog handlers specified in the drivers config array |
||
73 | * @return void |
||
74 | */ |
||
75 | 36 | protected function attachDrivers() |
|
83 | |||
84 | /** |
||
85 | * System is unusable. |
||
86 | * |
||
87 | * @param string $message |
||
88 | * @param array $context |
||
89 | * @return null |
||
90 | */ |
||
91 | 3 | public function emergency($message, array $context = array()) |
|
95 | |||
96 | /** |
||
97 | * Action must be taken immediately. |
||
98 | * |
||
99 | * Example: Entire website down, database unavailable, etc. This should |
||
100 | * trigger the SMS alerts and wake you up. |
||
101 | * |
||
102 | * @param string $message |
||
103 | * @param array $context |
||
104 | * @return null |
||
105 | */ |
||
106 | 3 | public function alert($message, array $context = array()) |
|
110 | |||
111 | /** |
||
112 | * Critical conditions. |
||
113 | * |
||
114 | * Example: Application component unavailable, unexpected exception. |
||
115 | * |
||
116 | * @param string $message |
||
117 | * @param array $context |
||
118 | * @return null |
||
119 | */ |
||
120 | 3 | public function critical($message, array $context = array()) |
|
124 | |||
125 | /** |
||
126 | * Runtime errors that do not require immediate action but should typically |
||
127 | * be logged and monitored. |
||
128 | * |
||
129 | * @param string $message |
||
130 | * @param array $context |
||
131 | * @return null |
||
132 | */ |
||
133 | 3 | public function error($message, array $context = array()) |
|
137 | |||
138 | /** |
||
139 | * Exceptional occurrences that are not errors. |
||
140 | * |
||
141 | * Example: Use of deprecated APIs, poor use of an API, undesirable things |
||
142 | * that are not necessarily wrong. |
||
143 | * |
||
144 | * @param string $message |
||
145 | * @param array $context |
||
146 | * @return null |
||
147 | */ |
||
148 | 3 | public function warning($message, array $context = array()) |
|
152 | |||
153 | /** |
||
154 | * Normal but significant events. |
||
155 | * |
||
156 | * @param string $message |
||
157 | * @param array $context |
||
158 | * @return null |
||
159 | */ |
||
160 | 3 | public function notice($message, array $context = array()) |
|
164 | |||
165 | /** |
||
166 | * Interesting events. |
||
167 | * |
||
168 | * Example: User logs in, SQL logs. |
||
169 | * |
||
170 | * @param string $message |
||
171 | * @param array $context |
||
172 | * @return null |
||
173 | */ |
||
174 | 3 | public function info($message, array $context = array()) |
|
178 | |||
179 | /** |
||
180 | * Detailed debug information. |
||
181 | * |
||
182 | * @param string $message |
||
183 | * @param array $context |
||
184 | * @return null |
||
185 | */ |
||
186 | 3 | public function debug($message, array $context = array()) |
|
190 | |||
191 | /** |
||
192 | * Logs with an arbitrary level. |
||
193 | * |
||
194 | * @param mixed $level |
||
195 | * @param string $message |
||
196 | * @param array $context |
||
197 | * @return null |
||
198 | */ |
||
199 | public function log($level, $message, array $context = array()) |
||
203 | |||
204 | } |