[Pkg-owncloud-commits] [owncloud] 39/69: Some expected Sabre exceptions are now logged with DEBUG level
David Prévot
taffit at moszumanska.debian.org
Sat May 10 16:20:37 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository owncloud.
commit 4a493c8835b606e9c2b74f275cb8c471adb5fa06
Author: Vincent Petry <pvince81 at owncloud.com>
Date: Mon May 5 11:31:25 2014 +0200
Some expected Sabre exceptions are now logged with DEBUG level
---
lib/private/connector/sabre/exceptionloggerplugin.php | 17 +++++++++++++++--
lib/public/util.php | 9 +++++----
2 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/lib/private/connector/sabre/exceptionloggerplugin.php b/lib/private/connector/sabre/exceptionloggerplugin.php
index 8e77afa..5eaf1e8 100644
--- a/lib/private/connector/sabre/exceptionloggerplugin.php
+++ b/lib/private/connector/sabre/exceptionloggerplugin.php
@@ -11,6 +11,17 @@
class OC_Connector_Sabre_ExceptionLoggerPlugin extends Sabre_DAV_ServerPlugin
{
+ private $nonFatalExceptions = array(
+ 'Sabre_DAV_Exception_NotAuthenticated' => true,
+ // the sync client uses this to find out whether files exist,
+ // so it is not always an error, log it as debug
+ 'Sabre_DAV_Exception_NotFound' => true,
+ // this one mostly happens when the same file is uploaded at
+ // exactly the same time from two clients, only one client
+ // wins, the second one gets "Precondition failed"
+ 'Sabre_DAV_Exception_PreconditionFailed' => true,
+ );
+
private $appName;
/**
@@ -43,8 +54,10 @@ class OC_Connector_Sabre_ExceptionLoggerPlugin extends Sabre_DAV_ServerPlugin
*/
public function logException($e) {
$exceptionClass = get_class($e);
- if ($exceptionClass !== 'Sabre_DAV_Exception_NotAuthenticated') {
- \OCP\Util::logException($this->appName, $e);
+ $level = \OCP\Util::FATAL;
+ if (isset($this->nonFatalExceptions[$exceptionClass])) {
+ $level = \OCP\Util::DEBUG;
}
+ \OCP\Util::logException($this->appName, $e, $level);
}
}
diff --git a/lib/public/util.php b/lib/public/util.php
index f06ddd6..3b0fc09 100644
--- a/lib/public/util.php
+++ b/lib/public/util.php
@@ -86,21 +86,22 @@ class Util {
* if DEBUG mode is enabled
* @param string $app app name
* @param \Exception $ex exception to log
+ * @param string $level log level, defaults to \OCP\Util::FATAL
*/
- public static function logException( $app, \Exception $ex ) {
+ public static function logException( $app, \Exception $ex, $level = \OCP\Util::FATAL ) {
$class = get_class($ex);
$message = $class . ': ' . $ex->getMessage();
if ($ex->getCode()) {
$message .= ' [' . $ex->getCode() . ']';
}
- \OCP\Util::writeLog($app, $message, \OCP\Util::FATAL);
+ \OCP\Util::writeLog($app, $message, $level);
if (defined('DEBUG') and DEBUG) {
// also log stack trace
$stack = explode("\n", $ex->getTraceAsString());
// first element is empty
array_shift($stack);
foreach ($stack as $s) {
- \OCP\Util::writeLog($app, 'Exception: ' . $s, \OCP\Util::FATAL);
+ \OCP\Util::writeLog($app, 'Exception: ' . $s, $level);
}
// include cause
@@ -110,7 +111,7 @@ class Util {
if ($ex->getCode()) {
$message .= '[' . $ex->getCode() . '] ';
}
- \OCP\Util::writeLog($app, 'Exception: ' . $message, \OCP\Util::FATAL);
+ \OCP\Util::writeLog($app, 'Exception: ' . $message, $level);
}
}
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list