@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | // interpolate $message as defined in PSR-3 |
211 | 211 | $replace = []; |
212 | 212 | foreach ($context as $key => $val) { |
213 | - $replace['{' . $key . '}'] = $val; |
|
213 | + $replace['{'.$key.'}'] = $val; |
|
214 | 214 | } |
215 | 215 | $message = strtr($message, $replace); |
216 | 216 | |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | } |
318 | 318 | |
319 | 319 | public function getLogPath():string { |
320 | - if($this->logger instanceof IFileBased) { |
|
320 | + if ($this->logger instanceof IFileBased) { |
|
321 | 321 | return $this->logger->getLogFilePath(); |
322 | 322 | } |
323 | 323 | throw new \RuntimeException('Log implementation has no path'); |
@@ -36,13 +36,11 @@ |
||
36 | 36 | namespace OC; |
37 | 37 | |
38 | 38 | use InterfaSys\LogNormalizer\Normalizer; |
39 | - |
|
40 | 39 | use OC\Log\ExceptionSerializer; |
41 | 40 | use OCP\Log\IFileBased; |
42 | 41 | use OCP\Log\IWriter; |
43 | 42 | use OCP\ILogger; |
44 | 43 | use OCP\Support\CrashReport\IRegistry; |
45 | -use OCP\Util; |
|
46 | 44 | |
47 | 45 | /** |
48 | 46 | * logging utilities |
@@ -55,271 +55,271 @@ |
||
55 | 55 | */ |
56 | 56 | class Log implements ILogger { |
57 | 57 | |
58 | - /** @var IWriter */ |
|
59 | - private $logger; |
|
60 | - |
|
61 | - /** @var SystemConfig */ |
|
62 | - private $config; |
|
63 | - |
|
64 | - /** @var boolean|null cache the result of the log condition check for the request */ |
|
65 | - private $logConditionSatisfied = null; |
|
66 | - |
|
67 | - /** @var Normalizer */ |
|
68 | - private $normalizer; |
|
69 | - |
|
70 | - /** @var IRegistry */ |
|
71 | - private $crashReporters; |
|
72 | - |
|
73 | - /** |
|
74 | - * @param IWriter $logger The logger that should be used |
|
75 | - * @param SystemConfig $config the system config object |
|
76 | - * @param Normalizer|null $normalizer |
|
77 | - * @param IRegistry|null $registry |
|
78 | - */ |
|
79 | - public function __construct(IWriter $logger, SystemConfig $config = null, $normalizer = null, IRegistry $registry = null) { |
|
80 | - // FIXME: Add this for backwards compatibility, should be fixed at some point probably |
|
81 | - if ($config === null) { |
|
82 | - $config = \OC::$server->getSystemConfig(); |
|
83 | - } |
|
84 | - |
|
85 | - $this->config = $config; |
|
86 | - $this->logger = $logger; |
|
87 | - if ($normalizer === null) { |
|
88 | - $this->normalizer = new Normalizer(); |
|
89 | - } else { |
|
90 | - $this->normalizer = $normalizer; |
|
91 | - } |
|
92 | - $this->crashReporters = $registry; |
|
93 | - } |
|
94 | - |
|
95 | - /** |
|
96 | - * System is unusable. |
|
97 | - * |
|
98 | - * @param string $message |
|
99 | - * @param array $context |
|
100 | - * @return void |
|
101 | - */ |
|
102 | - public function emergency(string $message, array $context = []) { |
|
103 | - $this->log(ILogger::FATAL, $message, $context); |
|
104 | - } |
|
105 | - |
|
106 | - /** |
|
107 | - * Action must be taken immediately. |
|
108 | - * |
|
109 | - * Example: Entire website down, database unavailable, etc. This should |
|
110 | - * trigger the SMS alerts and wake you up. |
|
111 | - * |
|
112 | - * @param string $message |
|
113 | - * @param array $context |
|
114 | - * @return void |
|
115 | - */ |
|
116 | - public function alert(string $message, array $context = []) { |
|
117 | - $this->log(ILogger::ERROR, $message, $context); |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * Critical conditions. |
|
122 | - * |
|
123 | - * Example: Application component unavailable, unexpected exception. |
|
124 | - * |
|
125 | - * @param string $message |
|
126 | - * @param array $context |
|
127 | - * @return void |
|
128 | - */ |
|
129 | - public function critical(string $message, array $context = []) { |
|
130 | - $this->log(ILogger::ERROR, $message, $context); |
|
131 | - } |
|
132 | - |
|
133 | - /** |
|
134 | - * Runtime errors that do not require immediate action but should typically |
|
135 | - * be logged and monitored. |
|
136 | - * |
|
137 | - * @param string $message |
|
138 | - * @param array $context |
|
139 | - * @return void |
|
140 | - */ |
|
141 | - public function error(string $message, array $context = []) { |
|
142 | - $this->log(ILogger::ERROR, $message, $context); |
|
143 | - } |
|
144 | - |
|
145 | - /** |
|
146 | - * Exceptional occurrences that are not errors. |
|
147 | - * |
|
148 | - * Example: Use of deprecated APIs, poor use of an API, undesirable things |
|
149 | - * that are not necessarily wrong. |
|
150 | - * |
|
151 | - * @param string $message |
|
152 | - * @param array $context |
|
153 | - * @return void |
|
154 | - */ |
|
155 | - public function warning(string $message, array $context = []) { |
|
156 | - $this->log(ILogger::WARN, $message, $context); |
|
157 | - } |
|
158 | - |
|
159 | - /** |
|
160 | - * Normal but significant events. |
|
161 | - * |
|
162 | - * @param string $message |
|
163 | - * @param array $context |
|
164 | - * @return void |
|
165 | - */ |
|
166 | - public function notice(string $message, array $context = []) { |
|
167 | - $this->log(ILogger::INFO, $message, $context); |
|
168 | - } |
|
169 | - |
|
170 | - /** |
|
171 | - * Interesting events. |
|
172 | - * |
|
173 | - * Example: User logs in, SQL logs. |
|
174 | - * |
|
175 | - * @param string $message |
|
176 | - * @param array $context |
|
177 | - * @return void |
|
178 | - */ |
|
179 | - public function info(string $message, array $context = []) { |
|
180 | - $this->log(ILogger::INFO, $message, $context); |
|
181 | - } |
|
182 | - |
|
183 | - /** |
|
184 | - * Detailed debug information. |
|
185 | - * |
|
186 | - * @param string $message |
|
187 | - * @param array $context |
|
188 | - * @return void |
|
189 | - */ |
|
190 | - public function debug(string $message, array $context = []) { |
|
191 | - $this->log(ILogger::DEBUG, $message, $context); |
|
192 | - } |
|
193 | - |
|
194 | - |
|
195 | - /** |
|
196 | - * Logs with an arbitrary level. |
|
197 | - * |
|
198 | - * @param int $level |
|
199 | - * @param string $message |
|
200 | - * @param array $context |
|
201 | - * @return void |
|
202 | - */ |
|
203 | - public function log(int $level, string $message, array $context = []) { |
|
204 | - $minLevel = $this->getLogLevel($context); |
|
205 | - |
|
206 | - array_walk($context, [$this->normalizer, 'format']); |
|
207 | - |
|
208 | - $app = $context['app'] ?? 'no app in context'; |
|
209 | - |
|
210 | - // interpolate $message as defined in PSR-3 |
|
211 | - $replace = []; |
|
212 | - foreach ($context as $key => $val) { |
|
213 | - $replace['{' . $key . '}'] = $val; |
|
214 | - } |
|
215 | - $message = strtr($message, $replace); |
|
216 | - |
|
217 | - if ($level >= $minLevel) { |
|
218 | - $this->writeLog($app, $message, $level); |
|
219 | - } |
|
220 | - } |
|
221 | - |
|
222 | - private function getLogLevel($context) { |
|
223 | - /** |
|
224 | - * check for a special log condition - this enables an increased log on |
|
225 | - * a per request/user base |
|
226 | - */ |
|
227 | - if ($this->logConditionSatisfied === null) { |
|
228 | - // default to false to just process this once per request |
|
229 | - $this->logConditionSatisfied = false; |
|
230 | - if (!empty($logCondition)) { |
|
231 | - |
|
232 | - // check for secret token in the request |
|
233 | - if (isset($logCondition['shared_secret'])) { |
|
234 | - $request = \OC::$server->getRequest(); |
|
235 | - |
|
236 | - // if token is found in the request change set the log condition to satisfied |
|
237 | - if ($request && hash_equals($logCondition['shared_secret'], $request->getParam('log_secret', ''))) { |
|
238 | - $this->logConditionSatisfied = true; |
|
239 | - } |
|
240 | - } |
|
241 | - |
|
242 | - // check for user |
|
243 | - if (isset($logCondition['users'])) { |
|
244 | - $user = \OC::$server->getUserSession()->getUser(); |
|
245 | - |
|
246 | - // if the user matches set the log condition to satisfied |
|
247 | - if ($user !== null && in_array($user->getUID(), $logCondition['users'], true)) { |
|
248 | - $this->logConditionSatisfied = true; |
|
249 | - } |
|
250 | - } |
|
251 | - } |
|
252 | - } |
|
253 | - |
|
254 | - // if log condition is satisfied change the required log level to DEBUG |
|
255 | - if ($this->logConditionSatisfied) { |
|
256 | - return ILogger::DEBUG; |
|
257 | - } |
|
258 | - |
|
259 | - if (isset($context['app'])) { |
|
260 | - $logCondition = $this->config->getValue('log.condition', []); |
|
261 | - $app = $context['app']; |
|
262 | - |
|
263 | - /** |
|
264 | - * check log condition based on the context of each log message |
|
265 | - * once this is met -> change the required log level to debug |
|
266 | - */ |
|
267 | - if (!empty($logCondition) |
|
268 | - && isset($logCondition['apps']) |
|
269 | - && in_array($app, $logCondition['apps'], true)) { |
|
270 | - return ILogger::DEBUG; |
|
271 | - } |
|
272 | - } |
|
273 | - |
|
274 | - return min($this->config->getValue('loglevel', ILogger::WARN), ILogger::FATAL); |
|
275 | - } |
|
276 | - |
|
277 | - /** |
|
278 | - * Logs an exception very detailed |
|
279 | - * |
|
280 | - * @param \Exception|\Throwable $exception |
|
281 | - * @param array $context |
|
282 | - * @return void |
|
283 | - * @since 8.2.0 |
|
284 | - */ |
|
285 | - public function logException(\Throwable $exception, array $context = []) { |
|
286 | - $app = $context['app'] ?? 'no app in context'; |
|
287 | - $level = $context['level'] ?? ILogger::ERROR; |
|
288 | - |
|
289 | - $serializer = new ExceptionSerializer(); |
|
290 | - $data = $serializer->serializeException($exception); |
|
291 | - $data['CustomMessage'] = $context['message'] ?? '--'; |
|
292 | - |
|
293 | - $minLevel = $this->getLogLevel($context); |
|
294 | - |
|
295 | - array_walk($context, [$this->normalizer, 'format']); |
|
296 | - |
|
297 | - if ($level >= $minLevel) { |
|
298 | - if (!$this->logger instanceof IFileBased) { |
|
299 | - $data = json_encode($data, JSON_PARTIAL_OUTPUT_ON_ERROR); |
|
300 | - } |
|
301 | - $this->writeLog($app, $data, $level); |
|
302 | - } |
|
303 | - |
|
304 | - $context['level'] = $level; |
|
305 | - if (!is_null($this->crashReporters)) { |
|
306 | - $this->crashReporters->delegateReport($exception, $context); |
|
307 | - } |
|
308 | - } |
|
309 | - |
|
310 | - /** |
|
311 | - * @param string $app |
|
312 | - * @param string|array $entry |
|
313 | - * @param int $level |
|
314 | - */ |
|
315 | - protected function writeLog(string $app, $entry, int $level) { |
|
316 | - $this->logger->write($app, $entry, $level); |
|
317 | - } |
|
318 | - |
|
319 | - public function getLogPath():string { |
|
320 | - if($this->logger instanceof IFileBased) { |
|
321 | - return $this->logger->getLogFilePath(); |
|
322 | - } |
|
323 | - throw new \RuntimeException('Log implementation has no path'); |
|
324 | - } |
|
58 | + /** @var IWriter */ |
|
59 | + private $logger; |
|
60 | + |
|
61 | + /** @var SystemConfig */ |
|
62 | + private $config; |
|
63 | + |
|
64 | + /** @var boolean|null cache the result of the log condition check for the request */ |
|
65 | + private $logConditionSatisfied = null; |
|
66 | + |
|
67 | + /** @var Normalizer */ |
|
68 | + private $normalizer; |
|
69 | + |
|
70 | + /** @var IRegistry */ |
|
71 | + private $crashReporters; |
|
72 | + |
|
73 | + /** |
|
74 | + * @param IWriter $logger The logger that should be used |
|
75 | + * @param SystemConfig $config the system config object |
|
76 | + * @param Normalizer|null $normalizer |
|
77 | + * @param IRegistry|null $registry |
|
78 | + */ |
|
79 | + public function __construct(IWriter $logger, SystemConfig $config = null, $normalizer = null, IRegistry $registry = null) { |
|
80 | + // FIXME: Add this for backwards compatibility, should be fixed at some point probably |
|
81 | + if ($config === null) { |
|
82 | + $config = \OC::$server->getSystemConfig(); |
|
83 | + } |
|
84 | + |
|
85 | + $this->config = $config; |
|
86 | + $this->logger = $logger; |
|
87 | + if ($normalizer === null) { |
|
88 | + $this->normalizer = new Normalizer(); |
|
89 | + } else { |
|
90 | + $this->normalizer = $normalizer; |
|
91 | + } |
|
92 | + $this->crashReporters = $registry; |
|
93 | + } |
|
94 | + |
|
95 | + /** |
|
96 | + * System is unusable. |
|
97 | + * |
|
98 | + * @param string $message |
|
99 | + * @param array $context |
|
100 | + * @return void |
|
101 | + */ |
|
102 | + public function emergency(string $message, array $context = []) { |
|
103 | + $this->log(ILogger::FATAL, $message, $context); |
|
104 | + } |
|
105 | + |
|
106 | + /** |
|
107 | + * Action must be taken immediately. |
|
108 | + * |
|
109 | + * Example: Entire website down, database unavailable, etc. This should |
|
110 | + * trigger the SMS alerts and wake you up. |
|
111 | + * |
|
112 | + * @param string $message |
|
113 | + * @param array $context |
|
114 | + * @return void |
|
115 | + */ |
|
116 | + public function alert(string $message, array $context = []) { |
|
117 | + $this->log(ILogger::ERROR, $message, $context); |
|
118 | + } |
|
119 | + |
|
120 | + /** |
|
121 | + * Critical conditions. |
|
122 | + * |
|
123 | + * Example: Application component unavailable, unexpected exception. |
|
124 | + * |
|
125 | + * @param string $message |
|
126 | + * @param array $context |
|
127 | + * @return void |
|
128 | + */ |
|
129 | + public function critical(string $message, array $context = []) { |
|
130 | + $this->log(ILogger::ERROR, $message, $context); |
|
131 | + } |
|
132 | + |
|
133 | + /** |
|
134 | + * Runtime errors that do not require immediate action but should typically |
|
135 | + * be logged and monitored. |
|
136 | + * |
|
137 | + * @param string $message |
|
138 | + * @param array $context |
|
139 | + * @return void |
|
140 | + */ |
|
141 | + public function error(string $message, array $context = []) { |
|
142 | + $this->log(ILogger::ERROR, $message, $context); |
|
143 | + } |
|
144 | + |
|
145 | + /** |
|
146 | + * Exceptional occurrences that are not errors. |
|
147 | + * |
|
148 | + * Example: Use of deprecated APIs, poor use of an API, undesirable things |
|
149 | + * that are not necessarily wrong. |
|
150 | + * |
|
151 | + * @param string $message |
|
152 | + * @param array $context |
|
153 | + * @return void |
|
154 | + */ |
|
155 | + public function warning(string $message, array $context = []) { |
|
156 | + $this->log(ILogger::WARN, $message, $context); |
|
157 | + } |
|
158 | + |
|
159 | + /** |
|
160 | + * Normal but significant events. |
|
161 | + * |
|
162 | + * @param string $message |
|
163 | + * @param array $context |
|
164 | + * @return void |
|
165 | + */ |
|
166 | + public function notice(string $message, array $context = []) { |
|
167 | + $this->log(ILogger::INFO, $message, $context); |
|
168 | + } |
|
169 | + |
|
170 | + /** |
|
171 | + * Interesting events. |
|
172 | + * |
|
173 | + * Example: User logs in, SQL logs. |
|
174 | + * |
|
175 | + * @param string $message |
|
176 | + * @param array $context |
|
177 | + * @return void |
|
178 | + */ |
|
179 | + public function info(string $message, array $context = []) { |
|
180 | + $this->log(ILogger::INFO, $message, $context); |
|
181 | + } |
|
182 | + |
|
183 | + /** |
|
184 | + * Detailed debug information. |
|
185 | + * |
|
186 | + * @param string $message |
|
187 | + * @param array $context |
|
188 | + * @return void |
|
189 | + */ |
|
190 | + public function debug(string $message, array $context = []) { |
|
191 | + $this->log(ILogger::DEBUG, $message, $context); |
|
192 | + } |
|
193 | + |
|
194 | + |
|
195 | + /** |
|
196 | + * Logs with an arbitrary level. |
|
197 | + * |
|
198 | + * @param int $level |
|
199 | + * @param string $message |
|
200 | + * @param array $context |
|
201 | + * @return void |
|
202 | + */ |
|
203 | + public function log(int $level, string $message, array $context = []) { |
|
204 | + $minLevel = $this->getLogLevel($context); |
|
205 | + |
|
206 | + array_walk($context, [$this->normalizer, 'format']); |
|
207 | + |
|
208 | + $app = $context['app'] ?? 'no app in context'; |
|
209 | + |
|
210 | + // interpolate $message as defined in PSR-3 |
|
211 | + $replace = []; |
|
212 | + foreach ($context as $key => $val) { |
|
213 | + $replace['{' . $key . '}'] = $val; |
|
214 | + } |
|
215 | + $message = strtr($message, $replace); |
|
216 | + |
|
217 | + if ($level >= $minLevel) { |
|
218 | + $this->writeLog($app, $message, $level); |
|
219 | + } |
|
220 | + } |
|
221 | + |
|
222 | + private function getLogLevel($context) { |
|
223 | + /** |
|
224 | + * check for a special log condition - this enables an increased log on |
|
225 | + * a per request/user base |
|
226 | + */ |
|
227 | + if ($this->logConditionSatisfied === null) { |
|
228 | + // default to false to just process this once per request |
|
229 | + $this->logConditionSatisfied = false; |
|
230 | + if (!empty($logCondition)) { |
|
231 | + |
|
232 | + // check for secret token in the request |
|
233 | + if (isset($logCondition['shared_secret'])) { |
|
234 | + $request = \OC::$server->getRequest(); |
|
235 | + |
|
236 | + // if token is found in the request change set the log condition to satisfied |
|
237 | + if ($request && hash_equals($logCondition['shared_secret'], $request->getParam('log_secret', ''))) { |
|
238 | + $this->logConditionSatisfied = true; |
|
239 | + } |
|
240 | + } |
|
241 | + |
|
242 | + // check for user |
|
243 | + if (isset($logCondition['users'])) { |
|
244 | + $user = \OC::$server->getUserSession()->getUser(); |
|
245 | + |
|
246 | + // if the user matches set the log condition to satisfied |
|
247 | + if ($user !== null && in_array($user->getUID(), $logCondition['users'], true)) { |
|
248 | + $this->logConditionSatisfied = true; |
|
249 | + } |
|
250 | + } |
|
251 | + } |
|
252 | + } |
|
253 | + |
|
254 | + // if log condition is satisfied change the required log level to DEBUG |
|
255 | + if ($this->logConditionSatisfied) { |
|
256 | + return ILogger::DEBUG; |
|
257 | + } |
|
258 | + |
|
259 | + if (isset($context['app'])) { |
|
260 | + $logCondition = $this->config->getValue('log.condition', []); |
|
261 | + $app = $context['app']; |
|
262 | + |
|
263 | + /** |
|
264 | + * check log condition based on the context of each log message |
|
265 | + * once this is met -> change the required log level to debug |
|
266 | + */ |
|
267 | + if (!empty($logCondition) |
|
268 | + && isset($logCondition['apps']) |
|
269 | + && in_array($app, $logCondition['apps'], true)) { |
|
270 | + return ILogger::DEBUG; |
|
271 | + } |
|
272 | + } |
|
273 | + |
|
274 | + return min($this->config->getValue('loglevel', ILogger::WARN), ILogger::FATAL); |
|
275 | + } |
|
276 | + |
|
277 | + /** |
|
278 | + * Logs an exception very detailed |
|
279 | + * |
|
280 | + * @param \Exception|\Throwable $exception |
|
281 | + * @param array $context |
|
282 | + * @return void |
|
283 | + * @since 8.2.0 |
|
284 | + */ |
|
285 | + public function logException(\Throwable $exception, array $context = []) { |
|
286 | + $app = $context['app'] ?? 'no app in context'; |
|
287 | + $level = $context['level'] ?? ILogger::ERROR; |
|
288 | + |
|
289 | + $serializer = new ExceptionSerializer(); |
|
290 | + $data = $serializer->serializeException($exception); |
|
291 | + $data['CustomMessage'] = $context['message'] ?? '--'; |
|
292 | + |
|
293 | + $minLevel = $this->getLogLevel($context); |
|
294 | + |
|
295 | + array_walk($context, [$this->normalizer, 'format']); |
|
296 | + |
|
297 | + if ($level >= $minLevel) { |
|
298 | + if (!$this->logger instanceof IFileBased) { |
|
299 | + $data = json_encode($data, JSON_PARTIAL_OUTPUT_ON_ERROR); |
|
300 | + } |
|
301 | + $this->writeLog($app, $data, $level); |
|
302 | + } |
|
303 | + |
|
304 | + $context['level'] = $level; |
|
305 | + if (!is_null($this->crashReporters)) { |
|
306 | + $this->crashReporters->delegateReport($exception, $context); |
|
307 | + } |
|
308 | + } |
|
309 | + |
|
310 | + /** |
|
311 | + * @param string $app |
|
312 | + * @param string|array $entry |
|
313 | + * @param int $level |
|
314 | + */ |
|
315 | + protected function writeLog(string $app, $entry, int $level) { |
|
316 | + $this->logger->write($app, $entry, $level); |
|
317 | + } |
|
318 | + |
|
319 | + public function getLogPath():string { |
|
320 | + if($this->logger instanceof IFileBased) { |
|
321 | + return $this->logger->getLogFilePath(); |
|
322 | + } |
|
323 | + throw new \RuntimeException('Log implementation has no path'); |
|
324 | + } |
|
325 | 325 | } |
@@ -55,7 +55,7 @@ |
||
55 | 55 | * @return StreamResponse |
56 | 56 | */ |
57 | 57 | public function download() { |
58 | - if(!$this->log instanceof Log) { |
|
58 | + if (!$this->log instanceof Log) { |
|
59 | 59 | throw new \UnexpectedValueException('Log file not available'); |
60 | 60 | } |
61 | 61 | $resp = new StreamResponse($this->log->getLogPath()); |
@@ -39,28 +39,28 @@ |
||
39 | 39 | */ |
40 | 40 | class LogSettingsController extends Controller { |
41 | 41 | |
42 | - /** @var ILogger */ |
|
43 | - private $log; |
|
42 | + /** @var ILogger */ |
|
43 | + private $log; |
|
44 | 44 | |
45 | - public function __construct(string $appName, IRequest $request, ILogger $logger) { |
|
46 | - parent::__construct($appName, $request); |
|
47 | - $this->log = $logger; |
|
48 | - } |
|
45 | + public function __construct(string $appName, IRequest $request, ILogger $logger) { |
|
46 | + parent::__construct($appName, $request); |
|
47 | + $this->log = $logger; |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * download logfile |
|
52 | - * |
|
53 | - * @NoCSRFRequired |
|
54 | - * |
|
55 | - * @return StreamResponse |
|
56 | - */ |
|
57 | - public function download() { |
|
58 | - if(!$this->log instanceof Log) { |
|
59 | - throw new \UnexpectedValueException('Log file not available'); |
|
60 | - } |
|
61 | - $resp = new StreamResponse($this->log->getLogPath()); |
|
62 | - $resp->addHeader('Content-Type', 'application/octet-stream'); |
|
63 | - $resp->addHeader('Content-Disposition', 'attachment; filename="nextcloud.log"'); |
|
64 | - return $resp; |
|
65 | - } |
|
50 | + /** |
|
51 | + * download logfile |
|
52 | + * |
|
53 | + * @NoCSRFRequired |
|
54 | + * |
|
55 | + * @return StreamResponse |
|
56 | + */ |
|
57 | + public function download() { |
|
58 | + if(!$this->log instanceof Log) { |
|
59 | + throw new \UnexpectedValueException('Log file not available'); |
|
60 | + } |
|
61 | + $resp = new StreamResponse($this->log->getLogPath()); |
|
62 | + $resp->addHeader('Content-Type', 'application/octet-stream'); |
|
63 | + $resp->addHeader('Content-Disposition', 'attachment; filename="nextcloud.log"'); |
|
64 | + return $resp; |
|
65 | + } |
|
66 | 66 | } |
@@ -29,14 +29,14 @@ |
||
29 | 29 | |
30 | 30 | class Errorlog implements IWriter { |
31 | 31 | |
32 | - /** |
|
33 | - * write a message in the log |
|
34 | - * @param string $app |
|
35 | - * @param string $message |
|
36 | - * @param int $level |
|
37 | - */ |
|
38 | - public function write(string $app, $message, int $level) { |
|
39 | - error_log('[owncloud]['.$app.']['.$level.'] '.$message); |
|
40 | - } |
|
32 | + /** |
|
33 | + * write a message in the log |
|
34 | + * @param string $app |
|
35 | + * @param string $message |
|
36 | + * @param int $level |
|
37 | + */ |
|
38 | + public function write(string $app, $message, int $level) { |
|
39 | + error_log('[owncloud]['.$app.']['.$level.'] '.$message); |
|
40 | + } |
|
41 | 41 | } |
42 | 42 |
@@ -32,17 +32,17 @@ |
||
32 | 32 | * @since 14.0.0 |
33 | 33 | */ |
34 | 34 | interface ILogFactory { |
35 | - /** |
|
36 | - * @param string $type - one of: file, errorlog, syslog |
|
37 | - * @return IWriter |
|
38 | - * @since 14.0.0 |
|
39 | - */ |
|
40 | - public function get(string $type): IWriter; |
|
35 | + /** |
|
36 | + * @param string $type - one of: file, errorlog, syslog |
|
37 | + * @return IWriter |
|
38 | + * @since 14.0.0 |
|
39 | + */ |
|
40 | + public function get(string $type): IWriter; |
|
41 | 41 | |
42 | - /** |
|
43 | - * @param string $path |
|
44 | - * @return ILogger |
|
45 | - * @since 14.0.0 |
|
46 | - */ |
|
47 | - public function getCustomLogger(string $path): ILogger; |
|
42 | + /** |
|
43 | + * @param string $path |
|
44 | + * @return ILogger |
|
45 | + * @since 14.0.0 |
|
46 | + */ |
|
47 | + public function getCustomLogger(string $path): ILogger; |
|
48 | 48 | } |
@@ -30,8 +30,8 @@ |
||
30 | 30 | * @since 14.0.0 |
31 | 31 | */ |
32 | 32 | interface IWriter { |
33 | - /** |
|
34 | - * @since 14.0.0 |
|
35 | - */ |
|
36 | - public function write(string $app, $message, int $level); |
|
33 | + /** |
|
34 | + * @since 14.0.0 |
|
35 | + */ |
|
36 | + public function write(string $app, $message, int $level); |
|
37 | 37 | } |
@@ -58,492 +58,492 @@ |
||
58 | 58 | */ |
59 | 59 | interface IServerContainer extends IContainer { |
60 | 60 | |
61 | - /** |
|
62 | - * The calendar manager will act as a broker between consumers for calendar information and |
|
63 | - * providers which actual deliver the calendar information. |
|
64 | - * |
|
65 | - * @return \OCP\Calendar\IManager |
|
66 | - * @since 13.0.0 |
|
67 | - */ |
|
68 | - public function getCalendarManager(); |
|
69 | - |
|
70 | - /** |
|
71 | - * The contacts manager will act as a broker between consumers for contacts information and |
|
72 | - * providers which actual deliver the contact information. |
|
73 | - * |
|
74 | - * @return \OCP\Contacts\IManager |
|
75 | - * @since 6.0.0 |
|
76 | - */ |
|
77 | - public function getContactsManager(); |
|
78 | - |
|
79 | - /** |
|
80 | - * The current request object holding all information about the request currently being processed |
|
81 | - * is returned from this method. |
|
82 | - * In case the current execution was not initiated by a web request null is returned |
|
83 | - * |
|
84 | - * @return \OCP\IRequest |
|
85 | - * @since 6.0.0 |
|
86 | - */ |
|
87 | - public function getRequest(); |
|
88 | - |
|
89 | - /** |
|
90 | - * Returns the preview manager which can create preview images for a given file |
|
91 | - * |
|
92 | - * @return \OCP\IPreview |
|
93 | - * @since 6.0.0 |
|
94 | - */ |
|
95 | - public function getPreviewManager(); |
|
96 | - |
|
97 | - /** |
|
98 | - * Returns the tag manager which can get and set tags for different object types |
|
99 | - * |
|
100 | - * @see \OCP\ITagManager::load() |
|
101 | - * @return \OCP\ITagManager |
|
102 | - * @since 6.0.0 |
|
103 | - */ |
|
104 | - public function getTagManager(); |
|
105 | - |
|
106 | - /** |
|
107 | - * Returns the root folder of ownCloud's data directory |
|
108 | - * |
|
109 | - * @return \OCP\Files\IRootFolder |
|
110 | - * @since 6.0.0 - between 6.0.0 and 8.0.0 this returned \OCP\Files\Folder |
|
111 | - */ |
|
112 | - public function getRootFolder(); |
|
113 | - |
|
114 | - /** |
|
115 | - * Returns a view to ownCloud's files folder |
|
116 | - * |
|
117 | - * @param string $userId user ID |
|
118 | - * @return \OCP\Files\Folder |
|
119 | - * @since 6.0.0 - parameter $userId was added in 8.0.0 |
|
120 | - * @see getUserFolder in \OCP\Files\IRootFolder |
|
121 | - */ |
|
122 | - public function getUserFolder($userId = null); |
|
123 | - |
|
124 | - /** |
|
125 | - * Returns an app-specific view in ownClouds data directory |
|
126 | - * |
|
127 | - * @return \OCP\Files\Folder |
|
128 | - * @since 6.0.0 |
|
129 | - * @deprecated 9.2.0 use IAppData |
|
130 | - */ |
|
131 | - public function getAppFolder(); |
|
132 | - |
|
133 | - /** |
|
134 | - * Returns a user manager |
|
135 | - * |
|
136 | - * @return \OCP\IUserManager |
|
137 | - * @since 8.0.0 |
|
138 | - */ |
|
139 | - public function getUserManager(); |
|
140 | - |
|
141 | - /** |
|
142 | - * Returns a group manager |
|
143 | - * |
|
144 | - * @return \OCP\IGroupManager |
|
145 | - * @since 8.0.0 |
|
146 | - */ |
|
147 | - public function getGroupManager(); |
|
148 | - |
|
149 | - /** |
|
150 | - * Returns the user session |
|
151 | - * |
|
152 | - * @return \OCP\IUserSession |
|
153 | - * @since 6.0.0 |
|
154 | - */ |
|
155 | - public function getUserSession(); |
|
156 | - |
|
157 | - /** |
|
158 | - * Returns the navigation manager |
|
159 | - * |
|
160 | - * @return \OCP\INavigationManager |
|
161 | - * @since 6.0.0 |
|
162 | - */ |
|
163 | - public function getNavigationManager(); |
|
164 | - |
|
165 | - /** |
|
166 | - * Returns the config manager |
|
167 | - * |
|
168 | - * @return \OCP\IConfig |
|
169 | - * @since 6.0.0 |
|
170 | - */ |
|
171 | - public function getConfig(); |
|
172 | - |
|
173 | - /** |
|
174 | - * Returns a Crypto instance |
|
175 | - * |
|
176 | - * @return \OCP\Security\ICrypto |
|
177 | - * @since 8.0.0 |
|
178 | - */ |
|
179 | - public function getCrypto(); |
|
180 | - |
|
181 | - /** |
|
182 | - * Returns a Hasher instance |
|
183 | - * |
|
184 | - * @return \OCP\Security\IHasher |
|
185 | - * @since 8.0.0 |
|
186 | - */ |
|
187 | - public function getHasher(); |
|
188 | - |
|
189 | - /** |
|
190 | - * Returns a SecureRandom instance |
|
191 | - * |
|
192 | - * @return \OCP\Security\ISecureRandom |
|
193 | - * @since 8.1.0 |
|
194 | - */ |
|
195 | - public function getSecureRandom(); |
|
196 | - |
|
197 | - /** |
|
198 | - * Returns a CredentialsManager instance |
|
199 | - * |
|
200 | - * @return \OCP\Security\ICredentialsManager |
|
201 | - * @since 9.0.0 |
|
202 | - */ |
|
203 | - public function getCredentialsManager(); |
|
204 | - |
|
205 | - /** |
|
206 | - * Returns the app config manager |
|
207 | - * |
|
208 | - * @return \OCP\IAppConfig |
|
209 | - * @since 7.0.0 |
|
210 | - */ |
|
211 | - public function getAppConfig(); |
|
212 | - |
|
213 | - /** |
|
214 | - * @return \OCP\L10N\IFactory |
|
215 | - * @since 8.2.0 |
|
216 | - */ |
|
217 | - public function getL10NFactory(); |
|
218 | - |
|
219 | - /** |
|
220 | - * get an L10N instance |
|
221 | - * @param string $app appid |
|
222 | - * @param string $lang |
|
223 | - * @return \OCP\IL10N |
|
224 | - * @since 6.0.0 - parameter $lang was added in 8.0.0 |
|
225 | - */ |
|
226 | - public function getL10N($app, $lang = null); |
|
227 | - |
|
228 | - /** |
|
229 | - * @return \OC\Encryption\Manager |
|
230 | - * @since 8.1.0 |
|
231 | - */ |
|
232 | - public function getEncryptionManager(); |
|
233 | - |
|
234 | - /** |
|
235 | - * @return \OC\Encryption\File |
|
236 | - * @since 8.1.0 |
|
237 | - */ |
|
238 | - public function getEncryptionFilesHelper(); |
|
239 | - |
|
240 | - /** |
|
241 | - * @return \OCP\Encryption\Keys\IStorage |
|
242 | - * @since 8.1.0 |
|
243 | - */ |
|
244 | - public function getEncryptionKeyStorage(); |
|
245 | - |
|
246 | - /** |
|
247 | - * Returns the URL generator |
|
248 | - * |
|
249 | - * @return \OCP\IURLGenerator |
|
250 | - * @since 6.0.0 |
|
251 | - */ |
|
252 | - public function getURLGenerator(); |
|
253 | - |
|
254 | - /** |
|
255 | - * Returns an ICache instance |
|
256 | - * |
|
257 | - * @return \OCP\ICache |
|
258 | - * @since 6.0.0 |
|
259 | - */ |
|
260 | - public function getCache(); |
|
261 | - |
|
262 | - /** |
|
263 | - * Returns an \OCP\CacheFactory instance |
|
264 | - * |
|
265 | - * @return \OCP\ICacheFactory |
|
266 | - * @since 7.0.0 |
|
267 | - */ |
|
268 | - public function getMemCacheFactory(); |
|
269 | - |
|
270 | - /** |
|
271 | - * Returns the current session |
|
272 | - * |
|
273 | - * @return \OCP\ISession |
|
274 | - * @since 6.0.0 |
|
275 | - */ |
|
276 | - public function getSession(); |
|
277 | - |
|
278 | - /** |
|
279 | - * Returns the activity manager |
|
280 | - * |
|
281 | - * @return \OCP\Activity\IManager |
|
282 | - * @since 6.0.0 |
|
283 | - */ |
|
284 | - public function getActivityManager(); |
|
285 | - |
|
286 | - /** |
|
287 | - * Returns the current session |
|
288 | - * |
|
289 | - * @return \OCP\IDBConnection |
|
290 | - * @since 6.0.0 |
|
291 | - */ |
|
292 | - public function getDatabaseConnection(); |
|
293 | - |
|
294 | - /** |
|
295 | - * Returns an avatar manager, used for avatar functionality |
|
296 | - * |
|
297 | - * @return \OCP\IAvatarManager |
|
298 | - * @since 6.0.0 |
|
299 | - */ |
|
300 | - public function getAvatarManager(); |
|
301 | - |
|
302 | - /** |
|
303 | - * Returns an job list for controlling background jobs |
|
304 | - * |
|
305 | - * @return \OCP\BackgroundJob\IJobList |
|
306 | - * @since 7.0.0 |
|
307 | - */ |
|
308 | - public function getJobList(); |
|
309 | - |
|
310 | - /** |
|
311 | - * Returns a logger instance |
|
312 | - * |
|
313 | - * @return \OCP\ILogger |
|
314 | - * @since 8.0.0 |
|
315 | - */ |
|
316 | - public function getLogger(); |
|
317 | - |
|
318 | - /** |
|
319 | - * returns a log factory instance |
|
320 | - * |
|
321 | - * @return ILogFactory |
|
322 | - * @since 14.0.0 |
|
323 | - */ |
|
324 | - public function getLogFactory(); |
|
325 | - |
|
326 | - /** |
|
327 | - * Returns a router for generating and matching urls |
|
328 | - * |
|
329 | - * @return \OCP\Route\IRouter |
|
330 | - * @since 7.0.0 |
|
331 | - */ |
|
332 | - public function getRouter(); |
|
333 | - |
|
334 | - /** |
|
335 | - * Returns a search instance |
|
336 | - * |
|
337 | - * @return \OCP\ISearch |
|
338 | - * @since 7.0.0 |
|
339 | - */ |
|
340 | - public function getSearch(); |
|
341 | - |
|
342 | - /** |
|
343 | - * Get the certificate manager for the user |
|
344 | - * |
|
345 | - * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
346 | - * @return \OCP\ICertificateManager | null if $userId is null and no user is logged in |
|
347 | - * @since 8.0.0 |
|
348 | - */ |
|
349 | - public function getCertificateManager($userId = null); |
|
350 | - |
|
351 | - /** |
|
352 | - * Create a new event source |
|
353 | - * |
|
354 | - * @return \OCP\IEventSource |
|
355 | - * @since 8.0.0 |
|
356 | - */ |
|
357 | - public function createEventSource(); |
|
358 | - |
|
359 | - /** |
|
360 | - * Returns an instance of the HTTP client service |
|
361 | - * |
|
362 | - * @return \OCP\Http\Client\IClientService |
|
363 | - * @since 8.1.0 |
|
364 | - */ |
|
365 | - public function getHTTPClientService(); |
|
366 | - |
|
367 | - /** |
|
368 | - * Get the active event logger |
|
369 | - * |
|
370 | - * @return \OCP\Diagnostics\IEventLogger |
|
371 | - * @since 8.0.0 |
|
372 | - */ |
|
373 | - public function getEventLogger(); |
|
374 | - |
|
375 | - /** |
|
376 | - * Get the active query logger |
|
377 | - * |
|
378 | - * The returned logger only logs data when debug mode is enabled |
|
379 | - * |
|
380 | - * @return \OCP\Diagnostics\IQueryLogger |
|
381 | - * @since 8.0.0 |
|
382 | - */ |
|
383 | - public function getQueryLogger(); |
|
384 | - |
|
385 | - /** |
|
386 | - * Get the manager for temporary files and folders |
|
387 | - * |
|
388 | - * @return \OCP\ITempManager |
|
389 | - * @since 8.0.0 |
|
390 | - */ |
|
391 | - public function getTempManager(); |
|
392 | - |
|
393 | - /** |
|
394 | - * Get the app manager |
|
395 | - * |
|
396 | - * @return \OCP\App\IAppManager |
|
397 | - * @since 8.0.0 |
|
398 | - */ |
|
399 | - public function getAppManager(); |
|
400 | - |
|
401 | - /** |
|
402 | - * Get the webroot |
|
403 | - * |
|
404 | - * @return string |
|
405 | - * @since 8.0.0 |
|
406 | - */ |
|
407 | - public function getWebRoot(); |
|
408 | - |
|
409 | - /** |
|
410 | - * @return \OCP\Files\Config\IMountProviderCollection |
|
411 | - * @since 8.0.0 |
|
412 | - */ |
|
413 | - public function getMountProviderCollection(); |
|
414 | - |
|
415 | - /** |
|
416 | - * Get the IniWrapper |
|
417 | - * |
|
418 | - * @return \bantu\IniGetWrapper\IniGetWrapper |
|
419 | - * @since 8.0.0 |
|
420 | - */ |
|
421 | - public function getIniWrapper(); |
|
422 | - /** |
|
423 | - * @return \OCP\Command\IBus |
|
424 | - * @since 8.1.0 |
|
425 | - */ |
|
426 | - public function getCommandBus(); |
|
427 | - |
|
428 | - /** |
|
429 | - * Creates a new mailer |
|
430 | - * |
|
431 | - * @return \OCP\Mail\IMailer |
|
432 | - * @since 8.1.0 |
|
433 | - */ |
|
434 | - public function getMailer(); |
|
435 | - |
|
436 | - /** |
|
437 | - * Get the locking provider |
|
438 | - * |
|
439 | - * @return \OCP\Lock\ILockingProvider |
|
440 | - * @since 8.1.0 |
|
441 | - */ |
|
442 | - public function getLockingProvider(); |
|
443 | - |
|
444 | - /** |
|
445 | - * @return \OCP\Files\Mount\IMountManager |
|
446 | - * @since 8.2.0 |
|
447 | - */ |
|
448 | - public function getMountManager(); |
|
449 | - |
|
450 | - /** |
|
451 | - * Get the MimeTypeDetector |
|
452 | - * |
|
453 | - * @return \OCP\Files\IMimeTypeDetector |
|
454 | - * @since 8.2.0 |
|
455 | - */ |
|
456 | - public function getMimeTypeDetector(); |
|
457 | - |
|
458 | - /** |
|
459 | - * Get the MimeTypeLoader |
|
460 | - * |
|
461 | - * @return \OCP\Files\IMimeTypeLoader |
|
462 | - * @since 8.2.0 |
|
463 | - */ |
|
464 | - public function getMimeTypeLoader(); |
|
465 | - |
|
466 | - /** |
|
467 | - * Get the EventDispatcher |
|
468 | - * |
|
469 | - * @return EventDispatcherInterface |
|
470 | - * @since 8.2.0 |
|
471 | - */ |
|
472 | - public function getEventDispatcher(); |
|
473 | - |
|
474 | - /** |
|
475 | - * Get the Notification Manager |
|
476 | - * |
|
477 | - * @return \OCP\Notification\IManager |
|
478 | - * @since 9.0.0 |
|
479 | - */ |
|
480 | - public function getNotificationManager(); |
|
481 | - |
|
482 | - /** |
|
483 | - * @return \OCP\Comments\ICommentsManager |
|
484 | - * @since 9.0.0 |
|
485 | - */ |
|
486 | - public function getCommentsManager(); |
|
487 | - |
|
488 | - /** |
|
489 | - * Returns the system-tag manager |
|
490 | - * |
|
491 | - * @return \OCP\SystemTag\ISystemTagManager |
|
492 | - * |
|
493 | - * @since 9.0.0 |
|
494 | - */ |
|
495 | - public function getSystemTagManager(); |
|
496 | - |
|
497 | - /** |
|
498 | - * Returns the system-tag object mapper |
|
499 | - * |
|
500 | - * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
501 | - * |
|
502 | - * @since 9.0.0 |
|
503 | - */ |
|
504 | - public function getSystemTagObjectMapper(); |
|
505 | - |
|
506 | - /** |
|
507 | - * Returns the share manager |
|
508 | - * |
|
509 | - * @return \OCP\Share\IManager |
|
510 | - * @since 9.0.0 |
|
511 | - */ |
|
512 | - public function getShareManager(); |
|
513 | - |
|
514 | - /** |
|
515 | - * @return IContentSecurityPolicyManager |
|
516 | - * @since 9.0.0 |
|
517 | - */ |
|
518 | - public function getContentSecurityPolicyManager(); |
|
519 | - |
|
520 | - /** |
|
521 | - * @return \OCP\IDateTimeZone |
|
522 | - * @since 8.0.0 |
|
523 | - */ |
|
524 | - public function getDateTimeZone(); |
|
525 | - |
|
526 | - /** |
|
527 | - * @return \OCP\IDateTimeFormatter |
|
528 | - * @since 8.0.0 |
|
529 | - */ |
|
530 | - public function getDateTimeFormatter(); |
|
531 | - |
|
532 | - /** |
|
533 | - * @return \OCP\Federation\ICloudIdManager |
|
534 | - * @since 12.0.0 |
|
535 | - */ |
|
536 | - public function getCloudIdManager(); |
|
537 | - |
|
538 | - /** |
|
539 | - * @return \OCP\Remote\Api\IApiFactory |
|
540 | - * @since 13.0.0 |
|
541 | - */ |
|
542 | - public function getRemoteApiFactory(); |
|
543 | - |
|
544 | - /** |
|
545 | - * @return \OCP\Remote\IInstanceFactory |
|
546 | - * @since 13.0.0 |
|
547 | - */ |
|
548 | - public function getRemoteInstanceFactory(); |
|
61 | + /** |
|
62 | + * The calendar manager will act as a broker between consumers for calendar information and |
|
63 | + * providers which actual deliver the calendar information. |
|
64 | + * |
|
65 | + * @return \OCP\Calendar\IManager |
|
66 | + * @since 13.0.0 |
|
67 | + */ |
|
68 | + public function getCalendarManager(); |
|
69 | + |
|
70 | + /** |
|
71 | + * The contacts manager will act as a broker between consumers for contacts information and |
|
72 | + * providers which actual deliver the contact information. |
|
73 | + * |
|
74 | + * @return \OCP\Contacts\IManager |
|
75 | + * @since 6.0.0 |
|
76 | + */ |
|
77 | + public function getContactsManager(); |
|
78 | + |
|
79 | + /** |
|
80 | + * The current request object holding all information about the request currently being processed |
|
81 | + * is returned from this method. |
|
82 | + * In case the current execution was not initiated by a web request null is returned |
|
83 | + * |
|
84 | + * @return \OCP\IRequest |
|
85 | + * @since 6.0.0 |
|
86 | + */ |
|
87 | + public function getRequest(); |
|
88 | + |
|
89 | + /** |
|
90 | + * Returns the preview manager which can create preview images for a given file |
|
91 | + * |
|
92 | + * @return \OCP\IPreview |
|
93 | + * @since 6.0.0 |
|
94 | + */ |
|
95 | + public function getPreviewManager(); |
|
96 | + |
|
97 | + /** |
|
98 | + * Returns the tag manager which can get and set tags for different object types |
|
99 | + * |
|
100 | + * @see \OCP\ITagManager::load() |
|
101 | + * @return \OCP\ITagManager |
|
102 | + * @since 6.0.0 |
|
103 | + */ |
|
104 | + public function getTagManager(); |
|
105 | + |
|
106 | + /** |
|
107 | + * Returns the root folder of ownCloud's data directory |
|
108 | + * |
|
109 | + * @return \OCP\Files\IRootFolder |
|
110 | + * @since 6.0.0 - between 6.0.0 and 8.0.0 this returned \OCP\Files\Folder |
|
111 | + */ |
|
112 | + public function getRootFolder(); |
|
113 | + |
|
114 | + /** |
|
115 | + * Returns a view to ownCloud's files folder |
|
116 | + * |
|
117 | + * @param string $userId user ID |
|
118 | + * @return \OCP\Files\Folder |
|
119 | + * @since 6.0.0 - parameter $userId was added in 8.0.0 |
|
120 | + * @see getUserFolder in \OCP\Files\IRootFolder |
|
121 | + */ |
|
122 | + public function getUserFolder($userId = null); |
|
123 | + |
|
124 | + /** |
|
125 | + * Returns an app-specific view in ownClouds data directory |
|
126 | + * |
|
127 | + * @return \OCP\Files\Folder |
|
128 | + * @since 6.0.0 |
|
129 | + * @deprecated 9.2.0 use IAppData |
|
130 | + */ |
|
131 | + public function getAppFolder(); |
|
132 | + |
|
133 | + /** |
|
134 | + * Returns a user manager |
|
135 | + * |
|
136 | + * @return \OCP\IUserManager |
|
137 | + * @since 8.0.0 |
|
138 | + */ |
|
139 | + public function getUserManager(); |
|
140 | + |
|
141 | + /** |
|
142 | + * Returns a group manager |
|
143 | + * |
|
144 | + * @return \OCP\IGroupManager |
|
145 | + * @since 8.0.0 |
|
146 | + */ |
|
147 | + public function getGroupManager(); |
|
148 | + |
|
149 | + /** |
|
150 | + * Returns the user session |
|
151 | + * |
|
152 | + * @return \OCP\IUserSession |
|
153 | + * @since 6.0.0 |
|
154 | + */ |
|
155 | + public function getUserSession(); |
|
156 | + |
|
157 | + /** |
|
158 | + * Returns the navigation manager |
|
159 | + * |
|
160 | + * @return \OCP\INavigationManager |
|
161 | + * @since 6.0.0 |
|
162 | + */ |
|
163 | + public function getNavigationManager(); |
|
164 | + |
|
165 | + /** |
|
166 | + * Returns the config manager |
|
167 | + * |
|
168 | + * @return \OCP\IConfig |
|
169 | + * @since 6.0.0 |
|
170 | + */ |
|
171 | + public function getConfig(); |
|
172 | + |
|
173 | + /** |
|
174 | + * Returns a Crypto instance |
|
175 | + * |
|
176 | + * @return \OCP\Security\ICrypto |
|
177 | + * @since 8.0.0 |
|
178 | + */ |
|
179 | + public function getCrypto(); |
|
180 | + |
|
181 | + /** |
|
182 | + * Returns a Hasher instance |
|
183 | + * |
|
184 | + * @return \OCP\Security\IHasher |
|
185 | + * @since 8.0.0 |
|
186 | + */ |
|
187 | + public function getHasher(); |
|
188 | + |
|
189 | + /** |
|
190 | + * Returns a SecureRandom instance |
|
191 | + * |
|
192 | + * @return \OCP\Security\ISecureRandom |
|
193 | + * @since 8.1.0 |
|
194 | + */ |
|
195 | + public function getSecureRandom(); |
|
196 | + |
|
197 | + /** |
|
198 | + * Returns a CredentialsManager instance |
|
199 | + * |
|
200 | + * @return \OCP\Security\ICredentialsManager |
|
201 | + * @since 9.0.0 |
|
202 | + */ |
|
203 | + public function getCredentialsManager(); |
|
204 | + |
|
205 | + /** |
|
206 | + * Returns the app config manager |
|
207 | + * |
|
208 | + * @return \OCP\IAppConfig |
|
209 | + * @since 7.0.0 |
|
210 | + */ |
|
211 | + public function getAppConfig(); |
|
212 | + |
|
213 | + /** |
|
214 | + * @return \OCP\L10N\IFactory |
|
215 | + * @since 8.2.0 |
|
216 | + */ |
|
217 | + public function getL10NFactory(); |
|
218 | + |
|
219 | + /** |
|
220 | + * get an L10N instance |
|
221 | + * @param string $app appid |
|
222 | + * @param string $lang |
|
223 | + * @return \OCP\IL10N |
|
224 | + * @since 6.0.0 - parameter $lang was added in 8.0.0 |
|
225 | + */ |
|
226 | + public function getL10N($app, $lang = null); |
|
227 | + |
|
228 | + /** |
|
229 | + * @return \OC\Encryption\Manager |
|
230 | + * @since 8.1.0 |
|
231 | + */ |
|
232 | + public function getEncryptionManager(); |
|
233 | + |
|
234 | + /** |
|
235 | + * @return \OC\Encryption\File |
|
236 | + * @since 8.1.0 |
|
237 | + */ |
|
238 | + public function getEncryptionFilesHelper(); |
|
239 | + |
|
240 | + /** |
|
241 | + * @return \OCP\Encryption\Keys\IStorage |
|
242 | + * @since 8.1.0 |
|
243 | + */ |
|
244 | + public function getEncryptionKeyStorage(); |
|
245 | + |
|
246 | + /** |
|
247 | + * Returns the URL generator |
|
248 | + * |
|
249 | + * @return \OCP\IURLGenerator |
|
250 | + * @since 6.0.0 |
|
251 | + */ |
|
252 | + public function getURLGenerator(); |
|
253 | + |
|
254 | + /** |
|
255 | + * Returns an ICache instance |
|
256 | + * |
|
257 | + * @return \OCP\ICache |
|
258 | + * @since 6.0.0 |
|
259 | + */ |
|
260 | + public function getCache(); |
|
261 | + |
|
262 | + /** |
|
263 | + * Returns an \OCP\CacheFactory instance |
|
264 | + * |
|
265 | + * @return \OCP\ICacheFactory |
|
266 | + * @since 7.0.0 |
|
267 | + */ |
|
268 | + public function getMemCacheFactory(); |
|
269 | + |
|
270 | + /** |
|
271 | + * Returns the current session |
|
272 | + * |
|
273 | + * @return \OCP\ISession |
|
274 | + * @since 6.0.0 |
|
275 | + */ |
|
276 | + public function getSession(); |
|
277 | + |
|
278 | + /** |
|
279 | + * Returns the activity manager |
|
280 | + * |
|
281 | + * @return \OCP\Activity\IManager |
|
282 | + * @since 6.0.0 |
|
283 | + */ |
|
284 | + public function getActivityManager(); |
|
285 | + |
|
286 | + /** |
|
287 | + * Returns the current session |
|
288 | + * |
|
289 | + * @return \OCP\IDBConnection |
|
290 | + * @since 6.0.0 |
|
291 | + */ |
|
292 | + public function getDatabaseConnection(); |
|
293 | + |
|
294 | + /** |
|
295 | + * Returns an avatar manager, used for avatar functionality |
|
296 | + * |
|
297 | + * @return \OCP\IAvatarManager |
|
298 | + * @since 6.0.0 |
|
299 | + */ |
|
300 | + public function getAvatarManager(); |
|
301 | + |
|
302 | + /** |
|
303 | + * Returns an job list for controlling background jobs |
|
304 | + * |
|
305 | + * @return \OCP\BackgroundJob\IJobList |
|
306 | + * @since 7.0.0 |
|
307 | + */ |
|
308 | + public function getJobList(); |
|
309 | + |
|
310 | + /** |
|
311 | + * Returns a logger instance |
|
312 | + * |
|
313 | + * @return \OCP\ILogger |
|
314 | + * @since 8.0.0 |
|
315 | + */ |
|
316 | + public function getLogger(); |
|
317 | + |
|
318 | + /** |
|
319 | + * returns a log factory instance |
|
320 | + * |
|
321 | + * @return ILogFactory |
|
322 | + * @since 14.0.0 |
|
323 | + */ |
|
324 | + public function getLogFactory(); |
|
325 | + |
|
326 | + /** |
|
327 | + * Returns a router for generating and matching urls |
|
328 | + * |
|
329 | + * @return \OCP\Route\IRouter |
|
330 | + * @since 7.0.0 |
|
331 | + */ |
|
332 | + public function getRouter(); |
|
333 | + |
|
334 | + /** |
|
335 | + * Returns a search instance |
|
336 | + * |
|
337 | + * @return \OCP\ISearch |
|
338 | + * @since 7.0.0 |
|
339 | + */ |
|
340 | + public function getSearch(); |
|
341 | + |
|
342 | + /** |
|
343 | + * Get the certificate manager for the user |
|
344 | + * |
|
345 | + * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
346 | + * @return \OCP\ICertificateManager | null if $userId is null and no user is logged in |
|
347 | + * @since 8.0.0 |
|
348 | + */ |
|
349 | + public function getCertificateManager($userId = null); |
|
350 | + |
|
351 | + /** |
|
352 | + * Create a new event source |
|
353 | + * |
|
354 | + * @return \OCP\IEventSource |
|
355 | + * @since 8.0.0 |
|
356 | + */ |
|
357 | + public function createEventSource(); |
|
358 | + |
|
359 | + /** |
|
360 | + * Returns an instance of the HTTP client service |
|
361 | + * |
|
362 | + * @return \OCP\Http\Client\IClientService |
|
363 | + * @since 8.1.0 |
|
364 | + */ |
|
365 | + public function getHTTPClientService(); |
|
366 | + |
|
367 | + /** |
|
368 | + * Get the active event logger |
|
369 | + * |
|
370 | + * @return \OCP\Diagnostics\IEventLogger |
|
371 | + * @since 8.0.0 |
|
372 | + */ |
|
373 | + public function getEventLogger(); |
|
374 | + |
|
375 | + /** |
|
376 | + * Get the active query logger |
|
377 | + * |
|
378 | + * The returned logger only logs data when debug mode is enabled |
|
379 | + * |
|
380 | + * @return \OCP\Diagnostics\IQueryLogger |
|
381 | + * @since 8.0.0 |
|
382 | + */ |
|
383 | + public function getQueryLogger(); |
|
384 | + |
|
385 | + /** |
|
386 | + * Get the manager for temporary files and folders |
|
387 | + * |
|
388 | + * @return \OCP\ITempManager |
|
389 | + * @since 8.0.0 |
|
390 | + */ |
|
391 | + public function getTempManager(); |
|
392 | + |
|
393 | + /** |
|
394 | + * Get the app manager |
|
395 | + * |
|
396 | + * @return \OCP\App\IAppManager |
|
397 | + * @since 8.0.0 |
|
398 | + */ |
|
399 | + public function getAppManager(); |
|
400 | + |
|
401 | + /** |
|
402 | + * Get the webroot |
|
403 | + * |
|
404 | + * @return string |
|
405 | + * @since 8.0.0 |
|
406 | + */ |
|
407 | + public function getWebRoot(); |
|
408 | + |
|
409 | + /** |
|
410 | + * @return \OCP\Files\Config\IMountProviderCollection |
|
411 | + * @since 8.0.0 |
|
412 | + */ |
|
413 | + public function getMountProviderCollection(); |
|
414 | + |
|
415 | + /** |
|
416 | + * Get the IniWrapper |
|
417 | + * |
|
418 | + * @return \bantu\IniGetWrapper\IniGetWrapper |
|
419 | + * @since 8.0.0 |
|
420 | + */ |
|
421 | + public function getIniWrapper(); |
|
422 | + /** |
|
423 | + * @return \OCP\Command\IBus |
|
424 | + * @since 8.1.0 |
|
425 | + */ |
|
426 | + public function getCommandBus(); |
|
427 | + |
|
428 | + /** |
|
429 | + * Creates a new mailer |
|
430 | + * |
|
431 | + * @return \OCP\Mail\IMailer |
|
432 | + * @since 8.1.0 |
|
433 | + */ |
|
434 | + public function getMailer(); |
|
435 | + |
|
436 | + /** |
|
437 | + * Get the locking provider |
|
438 | + * |
|
439 | + * @return \OCP\Lock\ILockingProvider |
|
440 | + * @since 8.1.0 |
|
441 | + */ |
|
442 | + public function getLockingProvider(); |
|
443 | + |
|
444 | + /** |
|
445 | + * @return \OCP\Files\Mount\IMountManager |
|
446 | + * @since 8.2.0 |
|
447 | + */ |
|
448 | + public function getMountManager(); |
|
449 | + |
|
450 | + /** |
|
451 | + * Get the MimeTypeDetector |
|
452 | + * |
|
453 | + * @return \OCP\Files\IMimeTypeDetector |
|
454 | + * @since 8.2.0 |
|
455 | + */ |
|
456 | + public function getMimeTypeDetector(); |
|
457 | + |
|
458 | + /** |
|
459 | + * Get the MimeTypeLoader |
|
460 | + * |
|
461 | + * @return \OCP\Files\IMimeTypeLoader |
|
462 | + * @since 8.2.0 |
|
463 | + */ |
|
464 | + public function getMimeTypeLoader(); |
|
465 | + |
|
466 | + /** |
|
467 | + * Get the EventDispatcher |
|
468 | + * |
|
469 | + * @return EventDispatcherInterface |
|
470 | + * @since 8.2.0 |
|
471 | + */ |
|
472 | + public function getEventDispatcher(); |
|
473 | + |
|
474 | + /** |
|
475 | + * Get the Notification Manager |
|
476 | + * |
|
477 | + * @return \OCP\Notification\IManager |
|
478 | + * @since 9.0.0 |
|
479 | + */ |
|
480 | + public function getNotificationManager(); |
|
481 | + |
|
482 | + /** |
|
483 | + * @return \OCP\Comments\ICommentsManager |
|
484 | + * @since 9.0.0 |
|
485 | + */ |
|
486 | + public function getCommentsManager(); |
|
487 | + |
|
488 | + /** |
|
489 | + * Returns the system-tag manager |
|
490 | + * |
|
491 | + * @return \OCP\SystemTag\ISystemTagManager |
|
492 | + * |
|
493 | + * @since 9.0.0 |
|
494 | + */ |
|
495 | + public function getSystemTagManager(); |
|
496 | + |
|
497 | + /** |
|
498 | + * Returns the system-tag object mapper |
|
499 | + * |
|
500 | + * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
501 | + * |
|
502 | + * @since 9.0.0 |
|
503 | + */ |
|
504 | + public function getSystemTagObjectMapper(); |
|
505 | + |
|
506 | + /** |
|
507 | + * Returns the share manager |
|
508 | + * |
|
509 | + * @return \OCP\Share\IManager |
|
510 | + * @since 9.0.0 |
|
511 | + */ |
|
512 | + public function getShareManager(); |
|
513 | + |
|
514 | + /** |
|
515 | + * @return IContentSecurityPolicyManager |
|
516 | + * @since 9.0.0 |
|
517 | + */ |
|
518 | + public function getContentSecurityPolicyManager(); |
|
519 | + |
|
520 | + /** |
|
521 | + * @return \OCP\IDateTimeZone |
|
522 | + * @since 8.0.0 |
|
523 | + */ |
|
524 | + public function getDateTimeZone(); |
|
525 | + |
|
526 | + /** |
|
527 | + * @return \OCP\IDateTimeFormatter |
|
528 | + * @since 8.0.0 |
|
529 | + */ |
|
530 | + public function getDateTimeFormatter(); |
|
531 | + |
|
532 | + /** |
|
533 | + * @return \OCP\Federation\ICloudIdManager |
|
534 | + * @since 12.0.0 |
|
535 | + */ |
|
536 | + public function getCloudIdManager(); |
|
537 | + |
|
538 | + /** |
|
539 | + * @return \OCP\Remote\Api\IApiFactory |
|
540 | + * @since 13.0.0 |
|
541 | + */ |
|
542 | + public function getRemoteApiFactory(); |
|
543 | + |
|
544 | + /** |
|
545 | + * @return \OCP\Remote\IInstanceFactory |
|
546 | + * @since 13.0.0 |
|
547 | + */ |
|
548 | + public function getRemoteInstanceFactory(); |
|
549 | 549 | } |
@@ -30,30 +30,30 @@ |
||
30 | 30 | use OCP\Log\IWriter; |
31 | 31 | |
32 | 32 | class Syslog implements IWriter { |
33 | - protected $levels = [ |
|
34 | - ILogger::DEBUG => LOG_DEBUG, |
|
35 | - ILogger::INFO => LOG_INFO, |
|
36 | - ILogger::WARN => LOG_WARNING, |
|
37 | - ILogger::ERROR => LOG_ERR, |
|
38 | - ILogger::FATAL => LOG_CRIT, |
|
39 | - ]; |
|
33 | + protected $levels = [ |
|
34 | + ILogger::DEBUG => LOG_DEBUG, |
|
35 | + ILogger::INFO => LOG_INFO, |
|
36 | + ILogger::WARN => LOG_WARNING, |
|
37 | + ILogger::ERROR => LOG_ERR, |
|
38 | + ILogger::FATAL => LOG_CRIT, |
|
39 | + ]; |
|
40 | 40 | |
41 | - public function __construct(IConfig $config) { |
|
42 | - openlog($config->getSystemValue('syslog_tag', 'ownCloud'), LOG_PID | LOG_CONS, LOG_USER); |
|
43 | - } |
|
41 | + public function __construct(IConfig $config) { |
|
42 | + openlog($config->getSystemValue('syslog_tag', 'ownCloud'), LOG_PID | LOG_CONS, LOG_USER); |
|
43 | + } |
|
44 | 44 | |
45 | - public function __destruct() { |
|
46 | - closelog(); |
|
47 | - } |
|
45 | + public function __destruct() { |
|
46 | + closelog(); |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * write a message in the log |
|
51 | - * @param string $app |
|
52 | - * @param string $message |
|
53 | - * @param int $level |
|
54 | - */ |
|
55 | - public function write(string $app, $message, int $level) { |
|
56 | - $syslog_level = $this->levels[$level]; |
|
57 | - syslog($syslog_level, '{'.$app.'} '.$message); |
|
58 | - } |
|
49 | + /** |
|
50 | + * write a message in the log |
|
51 | + * @param string $app |
|
52 | + * @param string $message |
|
53 | + * @param int $level |
|
54 | + */ |
|
55 | + public function write(string $app, $message, int $level) { |
|
56 | + $syslog_level = $this->levels[$level]; |
|
57 | + syslog($syslog_level, '{'.$app.'} '.$message); |
|
58 | + } |
|
59 | 59 | } |
@@ -31,13 +31,13 @@ |
||
31 | 31 | * @since 14.0.0 |
32 | 32 | */ |
33 | 33 | interface IFileBased { |
34 | - /** |
|
35 | - * @since 14.0.0 |
|
36 | - */ |
|
37 | - public function getLogFilePath():string; |
|
34 | + /** |
|
35 | + * @since 14.0.0 |
|
36 | + */ |
|
37 | + public function getLogFilePath():string; |
|
38 | 38 | |
39 | - /** |
|
40 | - * @since 14.0.0 |
|
41 | - */ |
|
42 | - public function getEntries(int $limit=50, int $offset=0): array; |
|
39 | + /** |
|
40 | + * @since 14.0.0 |
|
41 | + */ |
|
42 | + public function getEntries(int $limit=50, int $offset=0): array; |
|
43 | 43 | } |
@@ -39,5 +39,5 @@ |
||
39 | 39 | /** |
40 | 40 | * @since 14.0.0 |
41 | 41 | */ |
42 | - public function getEntries(int $limit=50, int $offset=0): array; |
|
42 | + public function getEntries(int $limit = 50, int $offset = 0): array; |
|
43 | 43 | } |
@@ -33,17 +33,17 @@ |
||
33 | 33 | * location and manage that with your own tools. |
34 | 34 | */ |
35 | 35 | class Rotate extends \OC\BackgroundJob\Job { |
36 | - use RotationTrait; |
|
36 | + use RotationTrait; |
|
37 | 37 | |
38 | - public function run($dummy) { |
|
39 | - $systemConfig = \OC::$server->getSystemConfig(); |
|
40 | - $this->filePath = $systemConfig->getValue('logfile', $systemConfig->getValue('datadirectory', \OC::$SERVERROOT . '/data') . '/nextcloud.log'); |
|
38 | + public function run($dummy) { |
|
39 | + $systemConfig = \OC::$server->getSystemConfig(); |
|
40 | + $this->filePath = $systemConfig->getValue('logfile', $systemConfig->getValue('datadirectory', \OC::$SERVERROOT . '/data') . '/nextcloud.log'); |
|
41 | 41 | |
42 | - $this->maxSize = \OC::$server->getConfig()->getSystemValue('log_rotate_size', 100 * 1024 * 1024); |
|
43 | - if($this->shouldRotateBySize()) { |
|
44 | - $rotatedFile = $this->rotate(); |
|
45 | - $msg = 'Log file "'.$this->filePath.'" was over '.$this->maxSize.' bytes, moved to "'.$rotatedFile.'"'; |
|
46 | - \OC::$server->getLogger()->warning($msg, ['app' => Rotate::class]); |
|
47 | - } |
|
48 | - } |
|
42 | + $this->maxSize = \OC::$server->getConfig()->getSystemValue('log_rotate_size', 100 * 1024 * 1024); |
|
43 | + if($this->shouldRotateBySize()) { |
|
44 | + $rotatedFile = $this->rotate(); |
|
45 | + $msg = 'Log file "'.$this->filePath.'" was over '.$this->maxSize.' bytes, moved to "'.$rotatedFile.'"'; |
|
46 | + \OC::$server->getLogger()->warning($msg, ['app' => Rotate::class]); |
|
47 | + } |
|
48 | + } |
|
49 | 49 | } |
@@ -37,10 +37,10 @@ |
||
37 | 37 | |
38 | 38 | public function run($dummy) { |
39 | 39 | $systemConfig = \OC::$server->getSystemConfig(); |
40 | - $this->filePath = $systemConfig->getValue('logfile', $systemConfig->getValue('datadirectory', \OC::$SERVERROOT . '/data') . '/nextcloud.log'); |
|
40 | + $this->filePath = $systemConfig->getValue('logfile', $systemConfig->getValue('datadirectory', \OC::$SERVERROOT.'/data').'/nextcloud.log'); |
|
41 | 41 | |
42 | 42 | $this->maxSize = \OC::$server->getConfig()->getSystemValue('log_rotate_size', 100 * 1024 * 1024); |
43 | - if($this->shouldRotateBySize()) { |
|
43 | + if ($this->shouldRotateBySize()) { |
|
44 | 44 | $rotatedFile = $this->rotate(); |
45 | 45 | $msg = 'Log file "'.$this->filePath.'" was over '.$this->maxSize.' bytes, moved to "'.$rotatedFile.'"'; |
46 | 46 | \OC::$server->getLogger()->warning($msg, ['app' => Rotate::class]); |