aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2013-10-23 16:29:17 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2013-10-23 16:29:17 +0200
commitefdbcbddef2d1bf018a24ddc1837475fb9301b79 (patch)
treecb64186f50cdc215ef4586e72d02604e2517c4d7
parentaf58360434cdd6cb808d80d20fdbd293e1c57f0c (diff)
parent8c69a5388eeb6414d866758debaced903b468d76 (diff)
downloadnextcloud-server-efdbcbddef2d1bf018a24ddc1837475fb9301b79.tar.gz
nextcloud-server-efdbcbddef2d1bf018a24ddc1837475fb9301b79.zip
Merge branch 'master' of github.com:owncloud/core
-rwxr-xr-xindex.php3
-rw-r--r--lib/public/util.php33
2 files changed, 35 insertions, 1 deletions
diff --git a/index.php b/index.php
index 40063fa6e05..0a2f15f9f5e 100755
--- a/index.php
+++ b/index.php
@@ -30,8 +30,9 @@ try {
OC::handleRequest();
} catch (Exception $ex) {
+ \OCP\Util::logException('index', $ex);
+
//show the user a detailed error page
- \OCP\Util::writeLog('index', $ex->getMessage(), \OCP\Util::FATAL);
OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR);
OC_Template::printExceptionErrorPage($ex);
}
diff --git a/lib/public/util.php b/lib/public/util.php
index b33f07b55e6..ed0622b8d16 100644
--- a/lib/public/util.php
+++ b/lib/public/util.php
@@ -78,6 +78,39 @@ class Util {
}
/**
+ * @brief write exception into the log. Include the stack trace
+ * if DEBUG mode is enabled
+ * @param Exception $ex exception to log
+ */
+ public static function logException( $app, \Exception $ex ) {
+ $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());
+ // first element is empty
+ array_shift($stack);
+ foreach ($stack as $s) {
+ \OCP\Util::writeLog($app, 'Exception: ' . $s, \OCP\Util::FATAL);
+ }
+
+ // include cause
+ $l = \OC_L10N::get('lib');
+ while (method_exists($ex, 'getPrevious') && $ex = $ex->getPrevious()) {
+ $message .= ' - '.$l->t('Caused by:').' ';
+ $message .= $ex->getMessage();
+ if ($ex->getCode()) {
+ $message .= '[' . $ex->getCode() . '] ';
+ }
+ \OCP\Util::writeLog($app, 'Exception: ' . $message, \OCP\Util::FATAL);
+ }
+ }
+ }
+
+ /**
* @brief get l10n object
* @param string $app
* @return OC_L10N