Total Complexity | 4 |
Total Lines | 55 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
21 | class LoggerConfig |
||
22 | { |
||
23 | /** |
||
24 | * Log levels mapped to integer values. |
||
25 | */ |
||
26 | const LOG_LEVELS = [ |
||
27 | 'debug' => 100, |
||
28 | 'info' => 200, |
||
29 | 'notice' => 250, |
||
30 | 'warning' => 300, |
||
31 | 'error' => 400, |
||
32 | 'critical' => 500, |
||
33 | 'alert' => 550, |
||
34 | 'emergency' => 600, |
||
35 | ]; |
||
36 | |||
37 | /** |
||
38 | * Default log level. |
||
39 | */ |
||
40 | const DEFAULT_LOG_LEVEL = 'error'; |
||
41 | |||
42 | /** |
||
43 | * @var string |
||
44 | */ |
||
45 | private static $logLevel = self::DEFAULT_LOG_LEVEL; |
||
46 | |||
47 | /** |
||
48 | * Set the application's log level. |
||
49 | * @param string $level |
||
50 | * @return void |
||
51 | */ |
||
52 | public static function setAppLogLevel(string $level): void |
||
53 | { |
||
54 | if (isset(self::LOG_LEVELS[$level])) { |
||
55 | self::$logLevel = $level; |
||
56 | } |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | * Get the integer value of the application's log level. |
||
61 | * @return int |
||
62 | */ |
||
63 | public static function getAppLogLevel(): int |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * Get the integer log level for a given error type. |
||
70 | * @param string $errorType |
||
71 | * @return int |
||
72 | */ |
||
73 | public static function getLogLevel(string $errorType): int |
||
78 |