1 | <?php |
||
9 | class MonologFactory |
||
10 | { |
||
11 | /** |
||
12 | * @var HandlerFactory |
||
13 | */ |
||
14 | private $handlerFactory; |
||
15 | |||
16 | /** |
||
17 | * @var ProcessorFactory |
||
18 | */ |
||
19 | private $processorFactory; |
||
20 | /** |
||
21 | * @var FormatterFactory |
||
22 | */ |
||
23 | private $formatterFactory; |
||
24 | |||
25 | /** |
||
26 | * Initializes a new MonologFactory. |
||
27 | * |
||
28 | * @param HandlerFactory $handlerFactory |
||
29 | * @param ProcessorFactory $processorFactory |
||
30 | * @param FormatterFactory $formatterFactory |
||
31 | */ |
||
32 | 12 | public function __construct( |
|
41 | |||
42 | /** |
||
43 | * @param string $name |
||
44 | * @param array $handlers |
||
45 | * An array of handlers in format of: |
||
46 | * [ |
||
47 | * HandlerClass::class => [ |
||
48 | * 'configKey' => 'value', |
||
49 | * ], |
||
50 | * ] |
||
51 | * |
||
52 | * @param array $processors |
||
53 | * An array of processors in format of: |
||
54 | * [ |
||
55 | * function ($record) { |
||
56 | * return $record; |
||
57 | * }, |
||
58 | * MyProcessor::class => [ |
||
59 | * 'configKey' => 'value', |
||
60 | * ], |
||
61 | * ] |
||
62 | * |
||
63 | * You can supply both callables and invokable classes. |
||
64 | * |
||
65 | * @return Logger |
||
66 | * |
||
67 | * @throws \yii\base\InvalidConfigException |
||
68 | * @throws \InvalidArgumentException |
||
69 | */ |
||
70 | 12 | public function make(string $name, array $handlers = [], array $processors = []): Logger |
|
77 | |||
78 | /** |
||
79 | * Returns an array of handlers based on the given configuration. |
||
80 | * |
||
81 | * @param array $handlerConfigs |
||
82 | * |
||
83 | * @see MonologFactory::make() for the array format. |
||
84 | * |
||
85 | * @return HandlerInterface[] |
||
86 | * |
||
87 | * @throws \yii\base\InvalidConfigException |
||
88 | * @throws \InvalidArgumentException |
||
89 | */ |
||
90 | 12 | private function makeHandlers(array $handlerConfigs) |
|
108 | |||
109 | /** |
||
110 | * Returns an array of processors based on the given configuration. |
||
111 | * |
||
112 | * @param array $processorConfigs |
||
113 | * |
||
114 | * @see MonologFactory::make() for the array format. |
||
115 | * |
||
116 | * @return callable[] |
||
117 | * |
||
118 | * @throws \yii\base\InvalidConfigException |
||
119 | * @throws \InvalidArgumentException |
||
120 | */ |
||
121 | 12 | private function makeProcessors(array $processorConfigs): array |
|
138 | |||
139 | /** |
||
140 | * Maps the given configurations with the given callable. |
||
141 | * |
||
142 | * @param array $config |
||
143 | * @param callable $mapFunction |
||
144 | * |
||
145 | * @return array |
||
146 | */ |
||
147 | private function mapConfigurations(array $config, callable $mapFunction): array |
||
159 | |||
160 | /** |
||
161 | * Returns the formatter from given handler config array. |
||
162 | * |
||
163 | * @param array $handlerConfig |
||
164 | * |
||
165 | * @return FormatterInterface|null |
||
166 | * |
||
167 | * @throws \yii\base\InvalidConfigException |
||
168 | * @throws \InvalidArgumentException |
||
169 | */ |
||
170 | 7 | private function getFormatterFromHandlerConfig(array $handlerConfig) |
|
181 | |||
182 | /** |
||
183 | * Returns processors from the given handler config array. |
||
184 | * |
||
185 | * @param array $handlerConfig |
||
186 | * |
||
187 | * @return callable[]|array |
||
188 | * |
||
189 | * @throws \yii\base\InvalidConfigException |
||
190 | * @throws \InvalidArgumentException |
||
191 | */ |
||
192 | 7 | private function getProcessorsFromHandlerConfig(array $handlerConfig): array |
|
200 | } |
||
201 |