1 | <?php |
||
24 | trait LoggerTrait |
||
25 | { |
||
26 | /** |
||
27 | * @var Logger|null |
||
28 | */ |
||
29 | private static $logger; |
||
30 | |||
31 | /** |
||
32 | * The log file name |
||
33 | * |
||
34 | * @return string |
||
35 | */ |
||
36 | abstract protected static function getLogFileName(): string; |
||
37 | |||
38 | /** |
||
39 | * @inheritdoc |
||
40 | */ |
||
41 | protected static function isDebugModeEnabled() |
||
45 | |||
46 | /** |
||
47 | * @return string |
||
48 | */ |
||
49 | public static function getLogFile(): string |
||
53 | |||
54 | /** |
||
55 | * @return Logger |
||
56 | */ |
||
57 | public static function getLogger(): Logger |
||
65 | |||
66 | /** |
||
67 | * @return Logger |
||
68 | */ |
||
69 | protected static function resolveLogger(): Logger |
||
86 | |||
87 | /** |
||
88 | * @return \Closure |
||
89 | */ |
||
90 | protected static function loggerComponent() |
||
104 | |||
105 | /** |
||
106 | * @return array |
||
107 | */ |
||
108 | protected static function loggerFileTarget() |
||
124 | |||
125 | /** |
||
126 | * @param string $fileName |
||
127 | * @return string |
||
128 | */ |
||
129 | private static function prepLogFileName(string $fileName): string |
||
135 | |||
136 | /** |
||
137 | * Logs a debug message. |
||
138 | * Trace messages are logged mainly for development purpose to see |
||
139 | * the execution work flow of some code. This method will only log |
||
140 | * a message when the application is in debug mode. |
||
141 | * @param string|array $message the message to be logged. This can be a simple string or a more |
||
142 | * complex data structure, such as array. |
||
143 | * @param string $category the category of the message. |
||
144 | * @since 2.0.14 |
||
145 | */ |
||
146 | public static function debug($message, $category = 'general') |
||
150 | |||
151 | /** |
||
152 | * Logs an error message. |
||
153 | * An error message is typically logged when an unrecoverable error occurs |
||
154 | * during the execution of an application. |
||
155 | * @param string|array $message the message to be logged. This can be a simple string or a more |
||
156 | * complex data structure, such as array. |
||
157 | * @param string $category the category of the message. |
||
158 | */ |
||
159 | public static function error($message, $category = 'general') |
||
163 | |||
164 | /** |
||
165 | * Logs a warning message. |
||
166 | * A warning message is typically logged when an error occurs while the execution |
||
167 | * can still continue. |
||
168 | * @param string|array $message the message to be logged. This can be a simple string or a more |
||
169 | * complex data structure, such as array. |
||
170 | * @param string $category the category of the message. |
||
171 | */ |
||
172 | public static function warning($message, $category = 'general') |
||
176 | |||
177 | /** |
||
178 | * Logs an informative message. |
||
179 | * An informative message is typically logged by an application to keep record of |
||
180 | * something important (e.g. an administrator logs in). |
||
181 | * @param string|array $message the message to be logged. This can be a simple string or a more |
||
182 | * complex data structure, such as array. |
||
183 | * @param string $category the category of the message. |
||
184 | */ |
||
185 | public static function info($message, $category = 'general') |
||
189 | } |
||
190 |