Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2013-10-23 12:47:26 +0400
committerVincent Petry <pvince81@owncloud.com>2013-10-23 12:48:27 +0400
commit42c58220def38d5f762dc0c422012b0210577463 (patch)
tree2b344494e62236fd6e0cf04801c72b4ba23dad31
parent83956b1703dbb12de264306664b629132cd21e0b (diff)
Moved logException to OCP\Util class
-rwxr-xr-xindex.php30
-rw-r--r--lib/public/util.php33
2 files changed, 34 insertions, 29 deletions
diff --git a/index.php b/index.php
index 1b9b4a58f7f..ab7333cf0e6 100755
--- a/index.php
+++ b/index.php
@@ -23,34 +23,6 @@
$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';
@@ -58,7 +30,7 @@ try {
OC::handleRequest();
} catch (Exception $ex) {
- logException($ex);
+ \OCP\Util::logException($ex);
//show the user a detailed error page
OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR);
diff --git a/lib/public/util.php b/lib/public/util.php
index b33f07b55e6..00ef863c24c 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( \Exception $ex ) {
+ $message = $ex->getMessage();
+ if ($ex->getCode()) {
+ $message .= ' [' . $ex->getCode() . ']';
+ }
+ \OCP\Util::writeLog('index', '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('index', '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('index', 'Exception: ' . $message, \OCP\Util::FATAL);
+ }
+ }
+ }
+
+ /**
* @brief get l10n object
* @param string $app
* @return OC_L10N