1 | <?php |
||
21 | class Logger extends Component implements LoggerInterface |
||
22 | { |
||
23 | /** |
||
24 | * The Yii2 category to use when logging |
||
25 | * |
||
26 | * @var string |
||
27 | */ |
||
28 | public $category = 'PSR-3'; |
||
29 | |||
30 | /** |
||
31 | * The logger |
||
32 | * |
||
33 | * @var null|YiiLogger |
||
34 | */ |
||
35 | public $logger; |
||
36 | |||
37 | /** |
||
38 | * The default level to use when an arbitrary level is used. |
||
39 | * |
||
40 | * @var string |
||
41 | */ |
||
42 | public $level = YiiLogger::LEVEL_INFO; |
||
43 | |||
44 | /** |
||
45 | * The PSR-3 to Yii2 log level map |
||
46 | * |
||
47 | * @var array |
||
48 | */ |
||
49 | public $map = [ |
||
50 | 'emergency' => YiiLogger::LEVEL_ERROR, |
||
51 | 'alert' => YiiLogger::LEVEL_ERROR, |
||
52 | 'critical' => YiiLogger::LEVEL_ERROR, |
||
53 | 'error' => YiiLogger::LEVEL_ERROR, |
||
54 | 'warning' => YiiLogger::LEVEL_WARNING, |
||
55 | 'notice' => YiiLogger::LEVEL_INFO, |
||
56 | 'info' => YiiLogger::LEVEL_INFO, |
||
57 | 'debug' => YiiLogger::LEVEL_TRACE, |
||
58 | ]; |
||
59 | |||
60 | /** |
||
61 | * @inheritdoc |
||
62 | */ |
||
63 | public function init() |
||
70 | |||
71 | /** |
||
72 | * Log a message, transforming from PSR3 to the closest Yii2. |
||
73 | * |
||
74 | * @inheritdoc |
||
75 | */ |
||
76 | public function log($level, $message, array $context = []) |
||
90 | |||
91 | /** |
||
92 | * @inheritdoc |
||
93 | */ |
||
94 | public function emergency($message, array $context = []) |
||
98 | |||
99 | /** |
||
100 | * @inheritdoc |
||
101 | */ |
||
102 | public function alert($message, array $context = []) |
||
106 | |||
107 | /** |
||
108 | * @inheritdoc |
||
109 | */ |
||
110 | public function critical($message, array $context = []) |
||
114 | |||
115 | /** |
||
116 | * @inheritdoc |
||
117 | */ |
||
118 | public function error($message, array $context = []) |
||
122 | |||
123 | /** |
||
124 | * @inheritdoc |
||
125 | */ |
||
126 | public function warning($message, array $context = []) |
||
130 | |||
131 | /** |
||
132 | * @inheritdoc |
||
133 | */ |
||
134 | public function notice($message, array $context = []) |
||
138 | |||
139 | /** |
||
140 | * @inheritdoc |
||
141 | */ |
||
142 | public function info($message, array $context = []) |
||
146 | |||
147 | /** |
||
148 | * @inheritdoc |
||
149 | */ |
||
150 | public function debug($message, array $context = []) |
||
154 | |||
155 | /** |
||
156 | * Interpolates context values into the message placeholders. |
||
157 | * |
||
158 | * @param string $message |
||
159 | * @param array $context |
||
160 | * @return string |
||
161 | */ |
||
162 | private function interpolate(string $message, array $context = []) |
||
176 | } |
||
177 |