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('DEBUG') and DEBUG) {
OC\Log\ErrorHandler::register(true);
set_exception_handler(array('OC_Template', 'printExceptionErrorPage'));
} else {
OC\Log\ErrorHandler::register();
OC\Log\ErrorHandler::setLogger(OC_Log::$object);
}
OC\Log\ErrorHandler::setLogger(OC_Log::$object);
}
// register the stream wrappers

View File

@ -23,10 +23,14 @@ class ErrorHandler {
return preg_replace('/\/\/(.*):(.*)@/', '//xxx:xxx@', $msg);
}
public static function register() {
public static function register($debug=false) {
$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'));
set_exception_handler(array($handler, 'onException'));
}
@ -57,7 +61,15 @@ class ErrorHandler {
return;
}
$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'));
}
}