1 | <?php |
||
10 | class Monolog |
||
11 | { |
||
12 | /** |
||
13 | * @const ERR_HANDLERS_LIST_FORMAT Exception code if config for handlers |
||
14 | * list have not a correct format |
||
15 | */ |
||
16 | const ERR_HANDLERS_LIST_FORMAT = 1318001; |
||
17 | |||
18 | /** |
||
19 | * @const ERR_HANDLER_INFOS_FORMAT Exception code if the handler infos is |
||
20 | * not in a correct format |
||
21 | */ |
||
22 | const ERR_HANDLER_INFOS_FORMAT = 1318002; |
||
23 | |||
24 | /** |
||
25 | * @const ERR_HANDLER_INFOS_MISSING_NAME Exception code if a handler not |
||
26 | * have declared name |
||
27 | */ |
||
28 | const ERR_HANDLER_INFOS_MISSING_NAME = 1318003; |
||
29 | |||
30 | /** |
||
31 | * @const ERR_HANDLER_NAME_NOT_A_STRING Exception code if a handler name |
||
32 | * value is not a string |
||
33 | */ |
||
34 | const ERR_HANDLER_NAME_NOT_A_STRING = 1318004; |
||
35 | |||
36 | /** |
||
37 | * @const ERR_HANDLER_CLASS_NOT_FOUND Exception code if a handler class |
||
38 | * has not been found |
||
39 | */ |
||
40 | const ERR_HANDLER_CLASS_NOT_FOUND = 1318005; |
||
41 | |||
42 | /** |
||
43 | * @var string $channelName The monolog channel name |
||
44 | */ |
||
45 | protected $channelName = ''; |
||
46 | |||
47 | /** |
||
48 | * @var \BFW\Config $config The config object containing the handlers list |
||
49 | */ |
||
50 | protected $config; |
||
51 | |||
52 | /** |
||
53 | * @var \Monolog\Logger $monolog The monolog logger object |
||
54 | */ |
||
55 | protected $monolog; |
||
56 | |||
57 | /** |
||
58 | * @var array $handlers List of all declared handler |
||
59 | */ |
||
60 | protected $handlers = []; |
||
61 | |||
62 | /** |
||
63 | * Populate properties |
||
64 | * Initialize monolog logger object |
||
65 | * |
||
66 | * @param string $channelName The monolog channel name |
||
67 | * @param \BFW\Config $config The config object containing handlers list |
||
68 | */ |
||
69 | public function __construct($channelName, \BFW\Config $config) |
||
75 | |||
76 | /** |
||
77 | * Get accessor to property channelName |
||
78 | * |
||
79 | * @return string |
||
80 | */ |
||
81 | public function getChannelName() |
||
85 | |||
86 | /** |
||
87 | * Get accessor to property config |
||
88 | * |
||
89 | * @return \BFW\Config |
||
90 | */ |
||
91 | public function getConfig() |
||
95 | |||
96 | /** |
||
97 | * Get accessor to property monolog |
||
98 | * |
||
99 | * @return \Monolog\Logger |
||
100 | */ |
||
101 | public function getMonolog() |
||
105 | |||
106 | /** |
||
107 | * Get accessor to property handlers |
||
108 | * |
||
109 | * @return array |
||
110 | */ |
||
111 | public function getHandlers() |
||
115 | |||
116 | /** |
||
117 | * Adding all handlers to monolog logger |
||
118 | * |
||
119 | * @param string $configKeyName The key name containing handlers list |
||
120 | * @param string $configFileName The config file name containing handlers |
||
121 | * list |
||
122 | * |
||
123 | * @throws \Exception |
||
124 | * |
||
125 | * @return void |
||
126 | */ |
||
127 | public function addAllHandlers( |
||
148 | |||
149 | /** |
||
150 | * Check and add a new handler to the logger |
||
151 | * |
||
152 | * @param \stdObject $handlerInfos Handler infos (name and args) |
||
153 | * |
||
154 | * @throws \Exception |
||
155 | * |
||
156 | * @return void |
||
157 | */ |
||
158 | protected function addNewHandler($handlerInfos) |
||
168 | |||
169 | /** |
||
170 | * Check the handler infos |
||
171 | * |
||
172 | * @param \stdObject $handlerInfos Handler infos (name and args) |
||
173 | * |
||
174 | * @throws \Exception |
||
175 | * |
||
176 | * @return void |
||
177 | */ |
||
178 | protected function checkHandlerInfos($handlerInfos) |
||
190 | |||
191 | /** |
||
192 | * Check the handler name |
||
193 | * |
||
194 | * @param \stdObject $handlerInfos Handler infos (name and args) |
||
195 | * |
||
196 | * @throws \Exception |
||
197 | * |
||
198 | * @return void |
||
199 | */ |
||
200 | protected function checkHandlerName($handlerInfos) |
||
223 | |||
224 | /** |
||
225 | * Check the handler arguments list |
||
226 | * |
||
227 | * @param \stdObject $handlerInfos Handler infos (name and args) |
||
228 | * |
||
229 | * @return void |
||
230 | */ |
||
231 | protected function checkHandlerArgs($handlerInfos) |
||
241 | } |
||
242 |