]> source.dussan.org Git - nextcloud-server.git/commitdiff
Respect the error level when logging
authorJoas Schilling <coding@schilljs.com>
Mon, 26 Apr 2021 12:18:18 +0000 (14:18 +0200)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Mon, 26 Apr 2021 15:14:53 +0000 (15:14 +0000)
Signed-off-by: Joas Schilling <coding@schilljs.com>
lib/private/Log/ErrorHandler.php

index e87da0b5d83ddab571ae0994c5dac4cab194847b..604de67a10848439afc6658060258b50ed01789b 100644 (file)
@@ -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;
+               }
        }
 }