diff options
-rw-r--r-- | lib/AppInfo/Application.php | 6 | ||||
-rw-r--r-- | lib/Command/Tail.php | 7 | ||||
-rw-r--r-- | lib/Command/Watch.php | 11 | ||||
-rw-r--r-- | lib/Controller/LogController.php | 6 | ||||
-rw-r--r-- | lib/Controller/PageController.php | 3 | ||||
-rw-r--r-- | lib/Log/Formatter.php | 15 | ||||
-rw-r--r-- | lib/Log/LogIterator.php | 12 | ||||
-rw-r--r-- | lib/Log/LogIteratorFactory.php | 5 | ||||
-rw-r--r-- | lib/Log/SearchFilter.php | 2 | ||||
-rw-r--r-- | lib/Settings/Admin.php | 1 | ||||
-rw-r--r-- | tests/Log/LogIteratorTest.php | 2 |
11 files changed, 32 insertions, 38 deletions
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 7aa0967..1b43fdb 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -1,4 +1,6 @@ -<?php declare(strict_types=1); +<?php + +declare(strict_types=1); /** * @copyright Copyright (c) 2018 Robin Appelman <robin@icewind.nl> * @@ -37,7 +39,7 @@ class Application extends App implements IBootstrap { } public function boot(IBootContext $context): void { - $context->getAppContainer()->registerService(Formatter::class, function(IAppContainer $c) { + $context->getAppContainer()->registerService(Formatter::class, function (IAppContainer $c) { return new Formatter(\OC::$SERVERROOT); }); } diff --git a/lib/Command/Tail.php b/lib/Command/Tail.php index d359597..ba57921 100644 --- a/lib/Command/Tail.php +++ b/lib/Command/Tail.php @@ -1,4 +1,6 @@ -<?php declare(strict_types=1); +<?php + +declare(strict_types=1); /** * @copyright Copyright (c) 2018 Robin Appelman <robin@icewind.nl> * @@ -33,7 +35,7 @@ use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Console\Terminal; class Tail extends Base { - const LEVELS = ['Debug', 'Info', 'Warning', 'Error', 'Fatal']; + public const LEVELS = ['Debug', 'Info', 'Warning', 'Error', 'Fatal']; private $formatter; private $logIteratorFactory; @@ -42,7 +44,6 @@ class Tail extends Base { parent::__construct(); $this->formatter = $formatter; $this->logIteratorFactory = $logIteratorFactory; - } protected function configure() { diff --git a/lib/Command/Watch.php b/lib/Command/Watch.php index 3c8d9fd..e4e384d 100644 --- a/lib/Command/Watch.php +++ b/lib/Command/Watch.php @@ -1,4 +1,6 @@ -<?php declare(strict_types=1); +<?php + +declare(strict_types=1); /** * @copyright Copyright (c) 2018 Robin Appelman <robin@icewind.nl> * @@ -25,15 +27,13 @@ use OC\Core\Command\Base; use OC\Core\Command\InterruptedException; use OCA\LogReader\Log\Formatter; use OCA\LogReader\Log\LogIteratorFactory; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Console\Terminal; class Watch extends Base { - const LEVELS = ['Debug', 'Info', 'Warning', 'Error', 'Fatal']; - const ALL_LEVELS = '11111'; + public const LEVELS = ['Debug', 'Info', 'Warning', 'Error', 'Fatal']; + public const ALL_LEVELS = '11111'; private $formatter; private $logIteratorFactory; @@ -42,7 +42,6 @@ class Watch extends Base { parent::__construct(); $this->formatter = $formatter; $this->logIteratorFactory = $logIteratorFactory; - } protected function configure() { diff --git a/lib/Controller/LogController.php b/lib/Controller/LogController.php index b2ee096..00b3cad 100644 --- a/lib/Controller/LogController.php +++ b/lib/Controller/LogController.php @@ -21,7 +21,6 @@ namespace OCA\LogReader\Controller; -use OCA\LogReader\Log\LogIterator; use OCA\LogReader\Log\LogIteratorFactory; use OCA\LogReader\Log\SearchFilter; use OCP\AppFramework\Controller; @@ -29,8 +28,6 @@ use OCP\AppFramework\Http\JSONResponse; use OCP\AppFramework\Http\TemplateResponse; use OCP\IConfig; use OCP\IRequest; -use OCP\Log\IFileBased; -use OCP\Log\ILogFactory; /** * Class LogController @@ -71,7 +68,6 @@ class LogController extends Controller { $iterator = $this->logIteratorFactory->getLogIterator($levels); $iterator->next(); return $iterator->current(); - } /** @@ -93,7 +89,6 @@ class LogController extends Controller { * @return JSONResponse */ public function poll($lastReqId, $levels = '11111') { - $cycles = 0; $maxCycles = 20; @@ -186,7 +181,6 @@ class LogController extends Controller { } protected function responseFromIterator(\Iterator $iterator, $count, $offset) { - $iterator->rewind(); for ($i = 0; $i < $offset; $i++) { $iterator->next(); diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index 3547598..9d294d8 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -36,7 +36,6 @@ class PageController extends Controller { * @return TemplateResponse */ public function index() { - $response = new TemplateResponse( $this->appName, 'index', @@ -48,6 +47,4 @@ class PageController extends Controller { return $response; } - - } diff --git a/lib/Log/Formatter.php b/lib/Log/Formatter.php index 328cd5b..71ecdab 100644 --- a/lib/Log/Formatter.php +++ b/lib/Log/Formatter.php @@ -1,4 +1,6 @@ -<?php declare(strict_types=1); +<?php + +declare(strict_types=1); /** * @copyright Copyright (c) 2018 Robin Appelman <robin@icewind.nl> * @@ -21,7 +23,6 @@ namespace OCA\LogReader\Log; - class Formatter { private $root; @@ -84,7 +85,7 @@ class Formatter { $className = $argument['__class__']; unset($argument['__class__']); return $leadingSpace . $className . ' ' . trim($this->formatArgument($argument, $whiteSpace, $depth, true)); - } else if (is_array($argument)) { + } elseif (is_array($argument)) { if (count($argument) === 0) { return $leadingSpace . ($forceObject ? '{}' : '[]'); } @@ -93,13 +94,13 @@ class Formatter { $keyWhitespace = str_repeat(' ', $whiteSpace * ($depth + 1)); return $leadingSpace . "{\n" . implode($glue, array_map(function ($key, $value) use ($whiteSpace, $depth, $keyWhitespace) { - return $keyWhitespace . $key . ':' . trim($this->formatArgument($value, $whiteSpace, $depth + 1)); - }, array_keys($argument), array_values($argument))) . ($whiteSpace ? "\n" : '') . $leadingSpace . '}'; + return $keyWhitespace . $key . ':' . trim($this->formatArgument($value, $whiteSpace, $depth + 1)); + }, array_keys($argument), array_values($argument))) . ($whiteSpace ? "\n" : '') . $leadingSpace . '}'; } else { return $leadingSpace . "[\n" . implode($glue, array_map(function ($value) use ($whiteSpace, $depth) { - return $this->formatArgument($value, $whiteSpace, $depth + 1); - }, $argument)) . ($whiteSpace ? "\n" : '') . $leadingSpace . ']'; + return $this->formatArgument($value, $whiteSpace, $depth + 1); + }, $argument)) . ($whiteSpace ? "\n" : '') . $leadingSpace . ']'; } } else { $value = json_encode($argument, $whiteSpace ? JSON_PRETTY_PRINT : 0); diff --git a/lib/Log/LogIterator.php b/lib/Log/LogIterator.php index 54218a3..bf94865 100644 --- a/lib/Log/LogIterator.php +++ b/lib/Log/LogIterator.php @@ -51,7 +51,7 @@ class LogIterator implements \Iterator { private $timezone; - const CHUNK_SIZE = 100; // how many chars do we try at once to find a new line + public const CHUNK_SIZE = 100; // how many chars do we try at once to find a new line /** * @param resource $handle @@ -66,13 +66,13 @@ class LogIterator implements \Iterator { $this->next(); } - function rewind() { + public function rewind() { fseek($this->handle, 0, SEEK_END); $this->position = ftell($this->handle) - self::CHUNK_SIZE; $this->currentKey = 0; } - function current() { + public function current() { $entry = json_decode($this->lastLine, true); if ($this->dateFormat !== \DateTime::ATOM) { if (isset($entry['time'])) { @@ -85,11 +85,11 @@ class LogIterator implements \Iterator { return $entry; } - function key() { + public function key() { return $this->currentKey; } - function next() { + public function next() { $this->currentLine = ''; // Loop through each character of the file looking for new lines @@ -119,7 +119,7 @@ class LogIterator implements \Iterator { } } - function valid() { + public function valid() { if (!is_resource($this->handle)) { return false; } diff --git a/lib/Log/LogIteratorFactory.php b/lib/Log/LogIteratorFactory.php index 532b024..00de3d9 100644 --- a/lib/Log/LogIteratorFactory.php +++ b/lib/Log/LogIteratorFactory.php @@ -1,4 +1,6 @@ -<?php declare(strict_types=1); +<?php + +declare(strict_types=1); /** * @copyright Copyright (c) 2018 Robin Appelman <robin@icewind.nl> * @@ -21,7 +23,6 @@ namespace OCA\LogReader\Log; - use OCP\IConfig; use OCP\Log\IFileBased; use OCP\Log\ILogFactory; diff --git a/lib/Log/SearchFilter.php b/lib/Log/SearchFilter.php index 6493339..268bf9b 100644 --- a/lib/Log/SearchFilter.php +++ b/lib/Log/SearchFilter.php @@ -63,7 +63,7 @@ class SearchFilter extends \FilterIterator { private function inMessage($message, $query) { if (is_string($message)) { return stripos($message, $query) !== false; - } else if (isset($message['Exception'])) { + } elseif (isset($message['Exception'])) { return stripos($message['Exception'], $query) !== false || stripos($message['Message'], $query) !== false; } diff --git a/lib/Settings/Admin.php b/lib/Settings/Admin.php index 92d2bf9..2d0ac5f 100644 --- a/lib/Settings/Admin.php +++ b/lib/Settings/Admin.php @@ -52,5 +52,4 @@ class Admin implements ISettings { public function getPriority() { return 90; } - } diff --git a/tests/Log/LogIteratorTest.php b/tests/Log/LogIteratorTest.php index 341a87e..b65a9c6 100644 --- a/tests/Log/LogIteratorTest.php +++ b/tests/Log/LogIteratorTest.php @@ -52,4 +52,4 @@ class LogIteratorTest extends TestCase { $this->assertEquals(2, $entries[0]['reqId']); $this->assertEquals(1, $entries[1]['reqId']); } -}
\ No newline at end of file +} |