also load error handler if debugging is enabled

This commit is contained in:
Bjoern Schiessle 2014-01-31 13:27:51 +01:00
parent 44b637470c
commit cf5277b558
2 changed files with 17 additions and 4 deletions

View File

@ -504,11 +504,12 @@ class OC {
if (!defined('PHPUNIT_RUN')) { if (!defined('PHPUNIT_RUN')) {
if (defined('DEBUG') and DEBUG) { if (defined('DEBUG') and DEBUG) {
OC\Log\ErrorHandler::register(true);
set_exception_handler(array('OC_Template', 'printExceptionErrorPage')); set_exception_handler(array('OC_Template', 'printExceptionErrorPage'));
} else { } else {
OC\Log\ErrorHandler::register(); OC\Log\ErrorHandler::register();
OC\Log\ErrorHandler::setLogger(OC_Log::$object);
} }
OC\Log\ErrorHandler::setLogger(OC_Log::$object);
} }
// register the stream wrappers // register the stream wrappers

View File

@ -23,10 +23,14 @@ class ErrorHandler {
return preg_replace('/\/\/(.*):(.*)@/', '//xxx:xxx@', $msg); return preg_replace('/\/\/(.*):(.*)@/', '//xxx:xxx@', $msg);
} }
public static function register() { public static function register($debug=false) {
$handler = new ErrorHandler(); $handler = new ErrorHandler();
set_error_handler(array($handler, 'onError')); if ($debug) {
set_error_handler(array($handler, 'onAll'), E_ALL);
} else {
set_error_handler(array($handler, 'onError'));
}
register_shutdown_function(array($handler, 'onShutdown')); register_shutdown_function(array($handler, 'onShutdown'));
set_exception_handler(array($handler, 'onException')); set_exception_handler(array($handler, 'onException'));
} }
@ -57,7 +61,15 @@ class ErrorHandler {
return; return;
} }
$msg = $message . ' at ' . $file . '#' . $line; $msg = $message . ' at ' . $file . '#' . $line;
self::$logger->warning(self::removePassword($msg), array('app' => 'PHP')); self::$logger->error(self::removePassword($msg), array('app' => 'PHP'));
} }
//Recoverable handler which catch all errors, warnings and notices
public static function onAll($number, $message, $file, $line) {
$msg = $message . ' at ' . $file . '#' . $line;
self::$logger->debug(self::removePassword($msg), array('app' => 'PHP'));
}
} }