| Total Complexity | 12 |
| Total Lines | 59 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 5 | class ForrestLogger |
||
| 6 | { |
||
| 7 | public const LEVEL_ERROR = 100; |
||
| 8 | public const LEVEL_WARN = 200; |
||
| 9 | public const LEVEL_INFO = 300; |
||
| 10 | |||
| 11 | /** |
||
| 12 | * @var Logger[] |
||
| 13 | */ |
||
| 14 | private static array $logger = []; |
||
| 15 | |||
| 16 | private static int $logLevel = self::LEVEL_ERROR; |
||
| 17 | |||
| 18 | private static array $levels = [ |
||
| 19 | self::LEVEL_ERROR, |
||
| 20 | self::LEVEL_WARN, |
||
| 21 | self::LEVEL_INFO |
||
| 22 | ]; |
||
| 23 | |||
| 24 | public static function setLogLevel(int $logLevel): void |
||
| 25 | { |
||
| 26 | if (!in_array($logLevel, self::$levels)) { |
||
| 27 | throw new \RuntimeException('The given log level (' . $logLevel . ') does not exists.'); |
||
| 28 | } |
||
| 29 | self::$logLevel = $logLevel; |
||
| 30 | } |
||
| 31 | |||
| 32 | public static function addLogger($key, Logger $logger): void |
||
| 33 | { |
||
| 34 | self::$logger[$key] = $logger; |
||
| 35 | } |
||
| 36 | |||
| 37 | public static function info($message): void |
||
| 44 | } |
||
| 45 | } |
||
| 46 | |||
| 47 | public static function warn($message): void |
||
| 54 | } |
||
| 55 | } |
||
| 56 | |||
| 57 | public static function error($message): void |
||
| 67 |