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 Logger |
||
48 | */ |
||
49 | public static function getLogger(): Logger |
||
57 | |||
58 | /** |
||
59 | * @return Logger |
||
60 | */ |
||
61 | protected static function resolveLogger(): Logger |
||
78 | |||
79 | /** |
||
80 | * @return \Closure |
||
81 | */ |
||
82 | protected static function loggerComponent() |
||
96 | |||
97 | /** |
||
98 | * @return array |
||
99 | */ |
||
100 | protected static function loggerFileTarget() |
||
116 | |||
117 | /** |
||
118 | * @param string $fileName |
||
119 | * @return string |
||
120 | */ |
||
121 | private static function prepLogFileName(string $fileName): string |
||
127 | |||
128 | /** |
||
129 | * Logs a debug message. |
||
130 | * Trace messages are logged mainly for development purpose to see |
||
131 | * the execution work flow of some code. This method will only log |
||
132 | * a message when the application is in debug mode. |
||
133 | * @param string|array $message the message to be logged. This can be a simple string or a more |
||
134 | * complex data structure, such as array. |
||
135 | * @param string $category the category of the message. |
||
136 | * @since 2.0.14 |
||
137 | */ |
||
138 | public static function debug($message, $category = 'general') |
||
142 | |||
143 | /** |
||
144 | * Logs an error message. |
||
145 | * An error message is typically logged when an unrecoverable error occurs |
||
146 | * during the execution of an application. |
||
147 | * @param string|array $message the message to be logged. This can be a simple string or a more |
||
148 | * complex data structure, such as array. |
||
149 | * @param string $category the category of the message. |
||
150 | */ |
||
151 | public static function error($message, $category = 'general') |
||
155 | |||
156 | /** |
||
157 | * Logs a warning message. |
||
158 | * A warning message is typically logged when an error occurs while the execution |
||
159 | * can still continue. |
||
160 | * @param string|array $message the message to be logged. This can be a simple string or a more |
||
161 | * complex data structure, such as array. |
||
162 | * @param string $category the category of the message. |
||
163 | */ |
||
164 | public static function warning($message, $category = 'general') |
||
168 | |||
169 | /** |
||
170 | * Logs an informative message. |
||
171 | * An informative message is typically logged by an application to keep record of |
||
172 | * something important (e.g. an administrator logs in). |
||
173 | * @param string|array $message the message to be logged. This can be a simple string or a more |
||
174 | * complex data structure, such as array. |
||
175 | * @param string $category the category of the message. |
||
176 | */ |
||
177 | public static function info($message, $category = 'general') |
||
181 | } |