|
25 | 25 | use OCA\LogReader\Log\SearchFilter;
|
26 | 26 | use OCP\AppFramework\Controller;
|
27 | 27 | use OCP\AppFramework\Http\JSONResponse;
|
28 |
| -use OCP\AppFramework\Http\TemplateResponse; |
29 | 28 | use OCP\IConfig;
|
30 | 29 | use OCP\IRequest;
|
31 | 30 |
|
@@ -53,16 +52,16 @@ public function __construct($appName,
|
53 | 52 | * @param int $count
|
54 | 53 | * @param int $offset
|
55 | 54 | * @param string $levels
|
56 |
| - * @return TemplateResponse |
| 55 | + * @return JSONResponse |
57 | 56 | */
|
58 |
| - public function get($count = 50, $offset = 0, $levels = '11111') { |
59 |
| - $logType = $this->config->getSystemValue('log_type','file'); |
| 57 | + public function get($count = 50, $offset = 0, $levels = '11111'): JSONResponse { |
| 58 | + $logType = $this->config->getSystemValue('log_type', 'file'); |
60 | 59 | if ($logType === 'file') { // we only support web access when `log_type` is set to `file` (the default)
|
61 | 60 | $iterator = $this->logIteratorFactory->getLogIterator($levels);
|
62 | 61 | return $this->responseFromIterator($iterator, $count, $offset);
|
63 | 62 | } else { // A log_type other than `file` seems to be configured so:
|
64 |
| - // * Generate a dummy entry so we don't error out |
65 |
| - // * Use the dummy entry to inform the admin to look elsewhere and/or correct their configuration |
| 63 | + // * Generate a dummy entry so we don't error out |
| 64 | + // * Use the dummy entry to inform the admin to look elsewhere and/or correct their configuration |
66 | 65 | $dummyLine["id"] = uniqid();
|
67 | 66 | $dummyLine["reqid"] = "00000000000000000000"; // irrelevant
|
68 | 67 | $dummyLine["level"] = 1; // INFO
|
@@ -113,7 +112,7 @@ public function poll(string $lastReqId, string $levels = '11111'): JSONResponse
|
113 | 112 | $cycles = 0;
|
114 | 113 | $maxCycles = 20;
|
115 | 114 |
|
116 |
| - $logType = $this->config->getSystemValue('log_type','file'); |
| 115 | + $logType = $this->config->getSystemValue('log_type', 'file'); |
117 | 116 | if ($logType !== 'file') { // we only support access when `log_type` is set to `file` (the default)
|
118 | 117 | // TODO: Don't even attempt polling in the front-end
|
119 | 118 | sleep(20);
|
@@ -156,11 +155,11 @@ public function poll(string $lastReqId, string $levels = '11111'): JSONResponse
|
156 | 155 | * @param int $count
|
157 | 156 | * @param int $offset
|
158 | 157 | * @param string $levels
|
159 |
| - * @return TemplateResponse |
| 158 | + * @return JSONResponse |
160 | 159 | *
|
161 | 160 | * @NoCSRFRequired
|
162 | 161 | */
|
163 |
| - public function search($query = '', $count = 50, $offset = 0, $levels = '11111') { |
| 162 | + public function search($query = '', $count = 50, $offset = 0, $levels = '11111'): JSONResponse { |
164 | 163 | $iterator = $this->logIteratorFactory->getLogIterator($levels);
|
165 | 164 | $iterator = new \LimitIterator($iterator, 0, 100000); // limit the number of message we search to avoid huge search times
|
166 | 165 | $iterator->rewind();
|
@@ -221,7 +220,7 @@ public function setLevels(string $levels): int {
|
221 | 220 | return $minLevel;
|
222 | 221 | }
|
223 | 222 |
|
224 |
| - protected function responseFromIterator(\Iterator $iterator, $count, $offset) { |
| 223 | + protected function responseFromIterator(\Iterator $iterator, $count, $offset): JSONResponse { |
225 | 224 | $iterator->rewind();
|
226 | 225 | for ($i = 0; $i < $offset; $i++) {
|
227 | 226 | $iterator->next();
|
|
0 commit comments