summaryrefslogtreecommitdiffstats
path: root/lib/private/Log
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2021-04-26 14:18:18 +0200
committerJoas Schilling <coding@schilljs.com>2021-04-26 14:18:18 +0200
commit8d9e5e0b915bab667a22307d67b2788f14c48f89 (patch)
tree4656d184671de3e7fc6e47a801d99296e542eaf8 /lib/private/Log
parentaa651fd629534e96432492c1a74e979b28222ce2 (diff)
downloadnextcloud-server-8d9e5e0b915bab667a22307d67b2788f14c48f89.tar.gz
nextcloud-server-8d9e5e0b915bab667a22307d67b2788f14c48f89.zip
Respect the error level when logging
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/Log')
-rw-r--r--lib/private/Log/ErrorHandler.php19
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/private/Log/ErrorHandler.php b/lib/private/Log/ErrorHandler.php
index 3f4c9ee64b1..b877bd7cb19 100644
--- a/lib/private/Log/ErrorHandler.php
+++ b/lib/private/Log/ErrorHandler.php
@@ -90,13 +90,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;
+ }
}
}