Total Complexity | 4 |
Total Lines | 52 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
20 | abstract class Logger |
||
21 | { |
||
22 | /** |
||
23 | * The logger. |
||
24 | * |
||
25 | * @var MonologLogger |
||
26 | */ |
||
27 | private static MonologLogger $logger; |
||
28 | |||
29 | /** |
||
30 | * Logger constructor. |
||
31 | */ |
||
32 | public static function load(string $index = 'main') |
||
|
|||
33 | { |
||
34 | self::$logger = new MonologLogger('core_logger'); |
||
35 | set_exception_handler(['static', 'exceptionHandler']); |
||
36 | try { |
||
37 | $timeZone = RegionalInfo::$config['timezone']; |
||
38 | self::$logger->setTimezone( |
||
39 | new DateTimeZone($timeZone) |
||
40 | ); |
||
41 | self::$logger->pushHandler(new StreamHandler(CONFIGURATION_DIR . '/core.log', MonologLogger::DEBUG)); |
||
42 | } catch (Exception $e) { |
||
43 | dump($e); |
||
44 | } |
||
45 | self::$logger->pushHandler(new FirePHPHandler()); |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * Catch the exception handler and adds to logger. |
||
50 | * |
||
51 | * @param Exception $e |
||
52 | */ |
||
53 | public static function exceptionHandler($e): void |
||
54 | { |
||
55 | FlashMessages::setError($e->getMessage()); |
||
56 | dump($e); |
||
57 | self::$logger->error( |
||
58 | 'Exception [' . $e->getCode() . ']: ' . $e->getMessage() . PHP_EOL |
||
59 | . $e->getFile() . ':' . $e->getLine() . PHP_EOL |
||
60 | . $e->getTraceAsString() |
||
61 | ); |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * Returns the logger. |
||
66 | * |
||
67 | * @return MonologLogger |
||
68 | */ |
||
69 | public static function getLogger(): MonologLogger |
||
72 | } |
||
73 | } |
||
74 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.