aboutsummaryrefslogtreecommitdiffstats
path: root/index.php
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2013-10-22 19:16:34 +0200
committerVincent Petry <pvince81@owncloud.com>2013-10-22 19:17:41 +0200
commit83956b1703dbb12de264306664b629132cd21e0b (patch)
treedd62cf0681056ae297fff7a230ed2f6e28be5a69 /index.php
parent0641365a1033b3e6b926a5e280f3bd2559e2ea23 (diff)
downloadnextcloud-server-83956b1703dbb12de264306664b629132cd21e0b.tar.gz
nextcloud-server-83956b1703dbb12de264306664b629132cd21e0b.zip
Expand exception stack trace in log in debug mode
Diffstat (limited to 'index.php')
-rwxr-xr-xindex.php31
1 files changed, 30 insertions, 1 deletions
diff --git a/index.php b/index.php
index 40063fa6e05..1b9b4a58f7f 100755
--- a/index.php
+++ b/index.php
@@ -23,6 +23,34 @@
$RUNTIME_NOAPPS = true; //no apps, yet
+function logException($ex) {
+ $message = $ex->getMessage();
+ if ($ex->getCode()) {
+ $message .= ' [' . $message . ']';
+ }
+ \OCP\Util::writeLog('index', $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('index', $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('index', $message, \OCP\Util::FATAL);
+ }
+ }
+}
+
try {
require_once 'lib/base.php';
@@ -30,8 +58,9 @@ try {
OC::handleRequest();
} catch (Exception $ex) {
+ logException($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);
}