Blame view
sources/lib/private/connector/sabre/exceptionloggerplugin.php
1.56 KB
|
a293d369c
|
1 2 3 4 5 6 7 8 9 10 |
<?php /** * ownCloud * * @author Vincent Petry * @copyright 2014 Vincent Petry <pvince81@owncloud.com> * * @license AGPL3 */ |
|
6d9380f96
|
11 |
class OC_Connector_Sabre_ExceptionLoggerPlugin extends \Sabre\DAV\ServerPlugin |
|
a293d369c
|
12 |
{
|
|
6d9380f96
|
13 14 15 16 17 18 19 20 21 22 |
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, ); |
|
a293d369c
|
23 24 25 26 27 28 29 30 31 32 33 34 |
private $appName;
/**
* @param string $loggerAppName app name to use when logging
*/
public function __construct($loggerAppName = 'webdav') {
$this->appName = $loggerAppName;
}
/**
* This initializes the plugin.
*
|
|
6d9380f96
|
35 |
* This function is called by \Sabre\DAV\Server, after |
|
a293d369c
|
36 37 38 39 |
* addPlugin is called. * * This method should set up the required event subscriptions. * |
|
6d9380f96
|
40 |
* @param \Sabre\DAV\Server $server |
|
a293d369c
|
41 42 |
* @return void */ |
|
6d9380f96
|
43 |
public function initialize(\Sabre\DAV\Server $server) {
|
|
a293d369c
|
44 45 46 47 48 49 50 51 52 53 54 |
$server->subscribeEvent('exception', array($this, 'logException'), 10);
}
/**
* Log exception
*
* @internal param Exception $e exception
*/
public function logException($e) {
$exceptionClass = get_class($e);
|
|
6d9380f96
|
55 56 57 |
$level = \OCP\Util::FATAL;
if (isset($this->nonFatalExceptions[$exceptionClass])) {
$level = \OCP\Util::DEBUG;
|
|
a293d369c
|
58 |
} |
|
6d9380f96
|
59 |
\OCP\Util::logException($this->appName, $e, $level); |
|
a293d369c
|
60 61 |
} } |