From 11ef12a1060f3e34312ae40c690f95765d7c5f89 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Thu, 23 Jan 2014 12:11:53 +0100 Subject: Added exception logger plugin for sabre connector Whenever an exception occurs in the sabre connector code or code called by it, it will be logged. This plugin approach is needed because Sabre already catches exceptions to return them to the client in the XML response, so they don't appear logged in the web server log. This will make it much easier to debug syncing issues. --- lib/public/util.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/public/util.php') diff --git a/lib/public/util.php b/lib/public/util.php index 8e85f9afc3f..e893a76d811 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -88,14 +88,18 @@ class Util { * @param Exception $ex exception to log */ public static function logException( $app, \Exception $ex ) { - $message = $ex->getMessage(); + $class = get_class($ex); + if ($class !== 'Exception') { + $message = $class . ': '; + } + $message .= $ex->getMessage(); if ($ex->getCode()) { $message .= ' [' . $ex->getCode() . ']'; } \OCP\Util::writeLog($app, 'Exception: ' . $message, \OCP\Util::FATAL); if (defined('DEBUG') and DEBUG) { // also log stack trace - $stack = explode('#', $ex->getTraceAsString()); + $stack = explode("\n", $ex->getTraceAsString()); // first element is empty array_shift($stack); foreach ($stack as $s) { -- cgit v1.2.3