Respect the error level when logging
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
0cb66c5ca0
commit
56d7b1a382
|
@ -89,13 +89,28 @@ 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:
|
||||||
|
case E_USER_NOTICE:
|
||||||
|
return ILogger::INFO;
|
||||||
|
|
||||||
|
case E_USER_ERROR:
|
||||||
|
default:
|
||||||
|
return ILogger::ERROR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue