From 56d7b1a382eec252af27a954b90acdf34c0d588b Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 26 Apr 2021 14:18:18 +0200 Subject: [PATCH] Respect the error level when logging Signed-off-by: Joas Schilling --- lib/private/Log/ErrorHandler.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/private/Log/ErrorHandler.php b/lib/private/Log/ErrorHandler.php index e87da0b5d83..604de67a108 100644 --- a/lib/private/Log/ErrorHandler.php +++ b/lib/private/Log/ErrorHandler.php @@ -89,13 +89,28 @@ class ErrorHandler { } $msg = $message . ' at ' . $file . '#' . $line; $e = new \Error(self::removePassword($msg)); - self::$logger->logException($e, ['app' => 'PHP']); + self::$logger->logException($e, ['app' => 'PHP', 'level' => self::errnoToLogLevel($number)]); } //Recoverable handler which catch all errors, warnings and notices public static function onAll($number, $message, $file, $line) { $msg = $message . ' at ' . $file . '#' . $line; $e = new \Error(self::removePassword($msg)); - self::$logger->logException($e, ['app' => 'PHP', 'level' => 0]); + self::$logger->logException($e, ['app' => 'PHP', 'level' => self::errnoToLogLevel($number)]); + } + + public static function errnoToLogLevel(int $errno): int { + switch ($errno) { + case E_USER_WARNING: + return ILogger::WARN; + + case E_USER_DEPRECATED: + case E_USER_NOTICE: + return ILogger::INFO; + + case E_USER_ERROR: + default: + return ILogger::ERROR; + } } } -- 2.39.5