server/lib/private/connector/sabre/exceptionloggerplugin.php
Vincent Petry 9f6dcb9d3e Sabre Update to 2.1
- VObject fixes for Sabre\VObject 3.3
- Remove VObject property workarounds
- Added prefetching for tags in sabre tags plugin
- Moved oc_properties logic to separate PropertyStorage backend (WIP)
- Fixed Sabre connector namespaces
- Improved files plugin to handle props on-demand
- Moved allowed props from server class to files plugin
- Fixed tags caching for files that are known to have no tags
  (less queries)
- Added/fixed unit tests for Sabre FilesPlugin, TagsPlugin
- Replace OC\Connector\Sabre\Request with direct call to
  httpRequest->setUrl()
- Fix exception detection in DAV client when using Sabre\DAV\Client
- Added setETag() on Node instead of using the static FileSystem
- Also preload tags/props when depth is infinity
2015-02-23 22:27:23 +01:00

55 lines
1.4 KiB
PHP

<?php
namespace OC\Connector\Sabre;
class 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;
/**
* @param string $loggerAppName app name to use when logging
*/
public function __construct($loggerAppName = 'webdav') {
$this->appName = $loggerAppName;
}
/**
* This initializes the plugin.
*
* This function is called by \Sabre\DAV\Server, after
* addPlugin is called.
*
* This method should set up the required event subscriptions.
*
* @param \Sabre\DAV\Server $server
* @return void
*/
public function initialize(\Sabre\DAV\Server $server) {
$server->on('exception', array($this, 'logException'), 10);
}
/**
* Log exception
*
* @internal param Exception $e exception
*/
public function logException($e) {
$exceptionClass = get_class($e);
$level = \OCP\Util::FATAL;
if (isset($this->nonFatalExceptions[$exceptionClass])) {
$level = \OCP\Util::DEBUG;
}
\OCP\Util::logException($this->appName, $e, $level);
}
}