Merge pull request #26767 from nextcloud/backport/26762/stable20

This commit is contained in:
Julius Härtl 2021-04-26 16:16:17 -01:00 committed by GitHub
commit 0f0c8debd9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 2 deletions

View File

@ -89,13 +89,30 @@ class ErrorHandler {
} }
$msg = $message . ' at ' . $file . '#' . $line; $msg = $message . ' at ' . $file . '#' . $line;
$e = new \Error(self::removePassword($msg)); $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 //Recoverable handler which catch all errors, warnings and notices
public static function onAll($number, $message, $file, $line) { public static function onAll($number, $message, $file, $line) {
$msg = $message . ' at ' . $file . '#' . $line; $msg = $message . ' at ' . $file . '#' . $line;
$e = new \Error(self::removePassword($msg)); $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:
return ILogger::DEBUG;
case E_USER_NOTICE:
return ILogger::INFO;
case E_USER_ERROR:
default:
return ILogger::ERROR;
}
} }
} }