diff --git a/lib/private/Log/PsrLoggerAdapter.php b/lib/private/Log/PsrLoggerAdapter.php index 79e9d4d96212a..888a482b92ccb 100644 --- a/lib/private/Log/PsrLoggerAdapter.php +++ b/lib/private/Log/PsrLoggerAdapter.php @@ -15,6 +15,7 @@ use Psr\Log\InvalidArgumentException; use Psr\Log\LoggerInterface; use Psr\Log\LogLevel; +use Stringable; use Throwable; use function array_key_exists; use function array_merge; @@ -27,14 +28,14 @@ public function __construct( public static function logLevelToInt(string $level): int { return match ($level) { - LogLevel::ALERT => ILogger::ERROR, - LogLevel::CRITICAL => ILogger::ERROR, - LogLevel::DEBUG => ILogger::DEBUG, LogLevel::EMERGENCY => ILogger::FATAL, - LogLevel::ERROR => ILogger::ERROR, - LogLevel::INFO => ILogger::INFO, - LogLevel::NOTICE => ILogger::INFO, + LogLevel::ALERT, + LogLevel::ERROR, + LogLevel::CRITICAL => ILogger::ERROR, LogLevel::WARNING => ILogger::WARN, + LogLevel::INFO, + LogLevel::NOTICE => ILogger::INFO, + LogLevel::DEBUG => ILogger::DEBUG, default => throw new InvalidArgumentException('Unsupported custom log level'), }; } @@ -50,10 +51,9 @@ private function containsThrowable(array $context): bool { /** * System is unusable. * - * @param $message * @param mixed[] $context */ - public function emergency($message, array $context = []): void { + public function emergency(string|Stringable $message, array $context = []): void { $this->log(LogLevel::EMERGENCY, (string)$message, $context); } @@ -63,10 +63,9 @@ public function emergency($message, array $context = []): void { * Example: Entire website down, database unavailable, etc. This should * trigger the SMS alerts and wake you up. * - * @param $message * @param mixed[] $context */ - public function alert($message, array $context = []): void { + public function alert(string|Stringable $message, array $context = []): void { $this->log(LogLevel::ALERT, (string)$message, $context); } @@ -75,10 +74,9 @@ public function alert($message, array $context = []): void { * * Example: Application component unavailable, unexpected exception. * - * @param $message * @param mixed[] $context */ - public function critical($message, array $context = []): void { + public function critical(string|Stringable $message, array $context = []): void { $this->log(LogLevel::CRITICAL, (string)$message, $context); } @@ -86,10 +84,9 @@ public function critical($message, array $context = []): void { * Runtime errors that do not require immediate action but should typically * be logged and monitored. * - * @param $message * @param mixed[] $context */ - public function error($message, array $context = []): void { + public function error(string|Stringable $message, array $context = []): void { $this->log(LogLevel::ERROR, (string)$message, $context); } @@ -99,20 +96,18 @@ public function error($message, array $context = []): void { * Example: Use of deprecated APIs, poor use of an API, undesirable things * that are not necessarily wrong. * - * @param $message * @param mixed[] $context */ - public function warning($message, array $context = []): void { + public function warning(string|Stringable $message, array $context = []): void { $this->log(LogLevel::WARNING, (string)$message, $context); } /** * Normal but significant events. * - * @param $message * @param mixed[] $context */ - public function notice($message, array $context = []): void { + public function notice(string|Stringable $message, array $context = []): void { $this->log(LogLevel::NOTICE, (string)$message, $context); } @@ -121,20 +116,18 @@ public function notice($message, array $context = []): void { * * Example: User logs in, SQL logs. * - * @param $message * @param mixed[] $context */ - public function info($message, array $context = []): void { + public function info(string|Stringable $message, array $context = []): void { $this->log(LogLevel::INFO, (string)$message, $context); } /** * Detailed debug information. * - * @param $message * @param mixed[] $context */ - public function debug($message, array $context = []): void { + public function debug(string|Stringable $message, array $context = []): void { $this->log(LogLevel::DEBUG, (string)$message, $context); } @@ -142,7 +135,6 @@ public function debug($message, array $context = []): void { * Logs with an arbitrary level. * * @param mixed $level - * @param $message * @param mixed[] $context * * @throws InvalidArgumentException