summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2014-01-31 13:27:51 +0100
committerBjoern Schiessle <schiessle@owncloud.com>2014-02-03 12:08:28 +0100
commitcf5277b558e1838a1b8126621cb8cd5a0ca60cb4 (patch)
tree79ee688b4de4c80a809b938033b9c733979adc16
parent44b637470c57f098d328bc6d298be9385d3f30c4 (diff)
downloadnextcloud-server-cf5277b558e1838a1b8126621cb8cd5a0ca60cb4.tar.gz
nextcloud-server-cf5277b558e1838a1b8126621cb8cd5a0ca60cb4.zip
also load error handler if debugging is enabled
-rw-r--r--lib/base.php3
-rw-r--r--lib/private/log/errorhandler.php18
2 files changed, 17 insertions, 4 deletions
diff --git a/lib/base.php b/lib/base.php
index af78b4e4eb1..b54b2973551 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -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
diff --git a/lib/private/log/errorhandler.php b/lib/private/log/errorhandler.php
index 4460468336b..f6c96ef8218 100644
--- a/lib/private/log/errorhandler.php
+++ b/lib/private/log/errorhandler.php
@@ -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'));
}
+
}