1 | <?php |
||
11 | class Yii2Monolog extends Component implements BootstrapInterface |
||
12 | { |
||
13 | /** |
||
14 | * @var array |
||
15 | */ |
||
16 | private $channels; |
||
17 | |||
18 | /** |
||
19 | * @var MonologFactory |
||
20 | */ |
||
21 | private $monologFactory; |
||
22 | |||
23 | /** |
||
24 | * @var string |
||
25 | */ |
||
26 | private $mainChannel; |
||
27 | |||
28 | /** |
||
29 | * @var LoggerRegistry |
||
30 | */ |
||
31 | private $loggerRegistry; |
||
32 | |||
33 | /** |
||
34 | * Initiates a new Yii2Monolog. |
||
35 | * |
||
36 | * @param MonologFactory $monologFactory |
||
37 | * @param LoggerRegistry $loggerRegistry |
||
38 | * @param array $config |
||
39 | */ |
||
40 | 9 | public function __construct(MonologFactory $monologFactory, LoggerRegistry $loggerRegistry, array $config = []) |
|
46 | |||
47 | /** |
||
48 | * Returns the given logger channel. |
||
49 | * |
||
50 | * @param null|string $channel |
||
51 | * |
||
52 | * @return Logger |
||
53 | */ |
||
54 | 6 | public function getLogger(string $channel = null): Logger |
|
62 | |||
63 | /** |
||
64 | * {@inheritdoc} |
||
65 | */ |
||
66 | 9 | public function bootstrap($app) |
|
71 | |||
72 | /** |
||
73 | * @param array $channelConfiguration |
||
74 | */ |
||
75 | 9 | public function setChannels(array $channelConfiguration) |
|
79 | |||
80 | /** |
||
81 | * @param string $channelName |
||
82 | */ |
||
83 | 2 | public function setMainChannel(string $channelName) |
|
87 | |||
88 | /** |
||
89 | * Registers loggers into Yii's DI container. |
||
90 | */ |
||
91 | 9 | private function registerLoggers() |
|
103 | |||
104 | /** |
||
105 | * Registers the main channel to be used for Psr LoggerInterface. |
||
106 | */ |
||
107 | private function registerPsrLogger() |
||
113 | |||
114 | /** |
||
115 | * Returns the main channel to be used for Yii2Monolog component. |
||
116 | * |
||
117 | * @return string |
||
118 | */ |
||
119 | 4 | private function getMainChannel(): string |
|
127 | } |
||
128 |