diff --git a/src/app/Enums/LogsLevelsEnum.php b/src/app/Enums/LogsLevelsEnum.php new file mode 100644 index 0000000..261b245 --- /dev/null +++ b/src/app/Enums/LogsLevelsEnum.php @@ -0,0 +1,27 @@ +logWithServices('info', $message, $customData); + $this->logWithServices(LogsLevelsEnum::INFO, $message, $customData); } /** @@ -90,7 +92,7 @@ trait LogTrait */ public function logNotice(string $message, array $customData = []): void { - $this->logWithServices('notice', $message, $customData); + $this->logWithServices(LogsLevelsEnum::NOTICE, $message, $customData); } /** @@ -100,7 +102,7 @@ trait LogTrait */ public function logWarning(string $message, array $customData = []): void { - $this->logWithServices('warning', $message, $customData); + $this->logWithServices(LogsLevelsEnum::WARNING, $message, $customData); } /** @@ -110,7 +112,7 @@ trait LogTrait */ public function logDebug(string $message, array $customData = []): void { - $this->logWithServices('debug', $message, $customData); + $this->logWithServices(LogsLevelsEnum::DEBUG, $message, $customData); } /** @@ -120,7 +122,7 @@ trait LogTrait */ public function logAlert(string $message, array $customData = []): void { - $this->logWithServices('alert', $message, $customData); + $this->logWithServices(LogsLevelsEnum::ALERT, $message, $customData); } /** @@ -131,11 +133,9 @@ trait LogTrait * @return LoggedExceptionDTO * @throws InvalidArgumentException */ - public function logException(string $caller, Throwable $exception, string $log_level = 'error', array $customData = []): LoggedExceptionDTO + public function logException(string $caller, Throwable $exception, string $log_level = LogsLevelsEnum::ERROR, array $customData = []): LoggedExceptionDTO { - $validLogLevels = ['emergency', 'critical', 'error']; - - if (!in_array($log_level, $validLogLevels, true)) { + if (!in_array($log_level, LogsLevelsEnum::allErrorLevels(), true)) { throw new InvalidArgumentException('Invalid log level specified'); }