@@ -37,79 +37,79 @@ |
||
37 | 37 | use Sabre\DAV\Exception\ServiceUnavailable; |
38 | 38 | |
39 | 39 | class ExceptionLoggerPlugin extends \Sabre\DAV\ServerPlugin { |
40 | - protected $nonFatalExceptions = [ |
|
41 | - NotAuthenticated::class => true, |
|
42 | - // If tokenauth can throw this exception (which is basically as |
|
43 | - // NotAuthenticated. So not fatal. |
|
44 | - PasswordLoginForbidden::class => true, |
|
45 | - // the sync client uses this to find out whether files exist, |
|
46 | - // so it is not always an error, log it as debug |
|
47 | - NotFound::class => true, |
|
48 | - // this one mostly happens when the same file is uploaded at |
|
49 | - // exactly the same time from two clients, only one client |
|
50 | - // wins, the second one gets "Precondition failed" |
|
51 | - PreconditionFailed::class => true, |
|
52 | - // forbidden can be expected when trying to upload to |
|
53 | - // read-only folders for example |
|
54 | - Forbidden::class => true, |
|
55 | - // Happens when an external storage or federated share is temporarily |
|
56 | - // not available |
|
57 | - StorageNotAvailableException::class => true, |
|
58 | - // happens if some a client uses the wrong method for a given URL |
|
59 | - // the error message itself is visible on the client side anyways |
|
60 | - NotImplemented::class => true, |
|
61 | - ]; |
|
40 | + protected $nonFatalExceptions = [ |
|
41 | + NotAuthenticated::class => true, |
|
42 | + // If tokenauth can throw this exception (which is basically as |
|
43 | + // NotAuthenticated. So not fatal. |
|
44 | + PasswordLoginForbidden::class => true, |
|
45 | + // the sync client uses this to find out whether files exist, |
|
46 | + // so it is not always an error, log it as debug |
|
47 | + NotFound::class => true, |
|
48 | + // this one mostly happens when the same file is uploaded at |
|
49 | + // exactly the same time from two clients, only one client |
|
50 | + // wins, the second one gets "Precondition failed" |
|
51 | + PreconditionFailed::class => true, |
|
52 | + // forbidden can be expected when trying to upload to |
|
53 | + // read-only folders for example |
|
54 | + Forbidden::class => true, |
|
55 | + // Happens when an external storage or federated share is temporarily |
|
56 | + // not available |
|
57 | + StorageNotAvailableException::class => true, |
|
58 | + // happens if some a client uses the wrong method for a given URL |
|
59 | + // the error message itself is visible on the client side anyways |
|
60 | + NotImplemented::class => true, |
|
61 | + ]; |
|
62 | 62 | |
63 | - /** @var string */ |
|
64 | - private $appName; |
|
63 | + /** @var string */ |
|
64 | + private $appName; |
|
65 | 65 | |
66 | - /** @var ILogger */ |
|
67 | - private $logger; |
|
66 | + /** @var ILogger */ |
|
67 | + private $logger; |
|
68 | 68 | |
69 | - /** |
|
70 | - * @param string $loggerAppName app name to use when logging |
|
71 | - * @param ILogger $logger |
|
72 | - */ |
|
73 | - public function __construct($loggerAppName, $logger) { |
|
74 | - $this->appName = $loggerAppName; |
|
75 | - $this->logger = $logger; |
|
76 | - } |
|
69 | + /** |
|
70 | + * @param string $loggerAppName app name to use when logging |
|
71 | + * @param ILogger $logger |
|
72 | + */ |
|
73 | + public function __construct($loggerAppName, $logger) { |
|
74 | + $this->appName = $loggerAppName; |
|
75 | + $this->logger = $logger; |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * This initializes the plugin. |
|
80 | - * |
|
81 | - * This function is called by \Sabre\DAV\Server, after |
|
82 | - * addPlugin is called. |
|
83 | - * |
|
84 | - * This method should set up the required event subscriptions. |
|
85 | - * |
|
86 | - * @param \Sabre\DAV\Server $server |
|
87 | - * @return void |
|
88 | - */ |
|
89 | - public function initialize(\Sabre\DAV\Server $server) { |
|
78 | + /** |
|
79 | + * This initializes the plugin. |
|
80 | + * |
|
81 | + * This function is called by \Sabre\DAV\Server, after |
|
82 | + * addPlugin is called. |
|
83 | + * |
|
84 | + * This method should set up the required event subscriptions. |
|
85 | + * |
|
86 | + * @param \Sabre\DAV\Server $server |
|
87 | + * @return void |
|
88 | + */ |
|
89 | + public function initialize(\Sabre\DAV\Server $server) { |
|
90 | 90 | |
91 | - $server->on('exception', array($this, 'logException'), 10); |
|
92 | - } |
|
91 | + $server->on('exception', array($this, 'logException'), 10); |
|
92 | + } |
|
93 | 93 | |
94 | - /** |
|
95 | - * Log exception |
|
96 | - * |
|
97 | - */ |
|
98 | - public function logException(\Exception $ex) { |
|
99 | - $exceptionClass = get_class($ex); |
|
100 | - $level = \OCP\Util::FATAL; |
|
101 | - if (isset($this->nonFatalExceptions[$exceptionClass]) || |
|
102 | - ( |
|
103 | - $exceptionClass === ServiceUnavailable::class && |
|
104 | - $ex->getMessage() === 'System in maintenance mode.' |
|
105 | - ) |
|
106 | - ) { |
|
107 | - $level = \OCP\Util::DEBUG; |
|
108 | - } |
|
94 | + /** |
|
95 | + * Log exception |
|
96 | + * |
|
97 | + */ |
|
98 | + public function logException(\Exception $ex) { |
|
99 | + $exceptionClass = get_class($ex); |
|
100 | + $level = \OCP\Util::FATAL; |
|
101 | + if (isset($this->nonFatalExceptions[$exceptionClass]) || |
|
102 | + ( |
|
103 | + $exceptionClass === ServiceUnavailable::class && |
|
104 | + $ex->getMessage() === 'System in maintenance mode.' |
|
105 | + ) |
|
106 | + ) { |
|
107 | + $level = \OCP\Util::DEBUG; |
|
108 | + } |
|
109 | 109 | |
110 | - $this->logger->logException($ex, [ |
|
111 | - 'app' => $this->appName, |
|
112 | - 'level' => $level, |
|
113 | - ]); |
|
114 | - } |
|
110 | + $this->logger->logException($ex, [ |
|
111 | + 'app' => $this->appName, |
|
112 | + 'level' => $level, |
|
113 | + ]); |
|
114 | + } |
|
115 | 115 | } |