| Total Complexity | 8 |
| Total Lines | 38 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 8 | class Logger |
||
| 9 | { |
||
| 10 | public const LOG_FILENAME = 'zoho_oauth.log'; |
||
| 11 | |||
| 12 | public static function warn($msg): void |
||
| 13 | { |
||
| 14 | self::writeToFile("WARNING: $msg"); |
||
| 15 | } |
||
| 16 | |||
| 17 | public static function writeToFile($msg): void |
||
| 18 | { |
||
| 19 | $path = defined('LOGGER_PATH') ? constant('LOGGER_PATH') : __DIR__ . '/../../../../'; |
||
| 20 | $filePointer = fopen($path . self::LOG_FILENAME, 'ab'); |
||
| 21 | if (!$filePointer) { |
||
| 22 | return; |
||
| 23 | } |
||
| 24 | fwrite($filePointer, sprintf("%s %s\n", date('Y-m-d H:i:s'), $msg)); |
||
| 25 | fclose($filePointer); |
||
| 26 | } |
||
| 27 | |||
| 28 | public static function info($msg): void |
||
| 29 | { |
||
| 30 | self::writeToFile("INFO: $msg"); |
||
| 31 | } |
||
| 32 | |||
| 33 | public static function severe($msg): void |
||
| 34 | { |
||
| 35 | self::writeToFile("SEVERE: $msg"); |
||
| 36 | } |
||
| 37 | |||
| 38 | public static function err($msg): void |
||
| 39 | { |
||
| 40 | self::writeToFile("ERROR: $msg"); |
||
| 41 | } |
||
| 42 | |||
| 43 | public static function debug($msg): void |
||
| 44 | { |
||
| 45 | self::writeToFile("DEBUG: $msg"); |
||
| 46 | } |
||
| 47 | } |