diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 42617ac8..3c0ca63d 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -21,7 +21,7 @@ checks: tools: external_code_coverage: timeout: 600 - runs: 3 + runs: 4 php_code_sniffer: enabled: true config: diff --git a/.travis.yml b/.travis.yml index d3d390c1..311b6ad1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,10 @@ language: php -sudo: false - php: - 7.1.3 - 7.1 - 7.2 + - 7.3 - nightly matrix: diff --git a/composer.json b/composer.json index a340ea3d..ca7d08f5 100644 --- a/composer.json +++ b/composer.json @@ -15,6 +15,7 @@ "license": "MIT", "require": { "php": ">=7.1.3", + "ext-json": "*", "psr/log": "~1.0", "arcanedev/support": "~4.3.0" }, diff --git a/src/Commands/CheckCommand.php b/src/Commands/CheckCommand.php index aca4acd9..21f5f389 100644 --- a/src/Commands/CheckCommand.php +++ b/src/Commands/CheckCommand.php @@ -99,7 +99,9 @@ private function displayMessages() $rows[] = [$file, $message]; } - $this->frame('LogViewer messages'); - $this->table(['File', 'Message'], $rows); + if ( ! empty($rows)) { + $this->frame('LogViewer messages'); + $this->table(['File', 'Message'], $rows); + } } } diff --git a/src/Utilities/LogChecker.php b/src/Utilities/LogChecker.php index 0d6afd2c..e82146aa 100644 --- a/src/Utilities/LogChecker.php +++ b/src/Utilities/LogChecker.php @@ -268,16 +268,17 @@ private function checkLogFile($path) $status = true; $filename = basename($path); $message = "The log file [$filename] is valid."; + $pattern = $this->filesystem->getPattern(); if ($this->isSingleLogFile($filename)) { - $this->status = $status = false; + $this->status = $status = false; $this->messages['files'][$filename] = $message = "You have a single log file in your application, you should split the [$filename] into separate log files."; } - elseif ($this->isInvalidLogDate($filename)) { - $this->status = $status = false; + elseif ($this->isInvalidLogPattern($filename, $pattern)) { + $this->status = $status = false; $this->messages['files'][$filename] = $message = - "The log file [$filename] has an invalid date, the format must be like laravel-YYYY-MM-DD.log."; + "The log file [$filename] has an invalid date, the format must be like {$pattern}."; } $this->files[$filename] = compact('filename', 'status', 'message', 'path'); @@ -299,13 +300,12 @@ private function isSingleLogFile($file) * Check the date of the log file. * * @param string $file + * @param string $pattern * * @return bool */ - private function isInvalidLogDate($file) + private function isInvalidLogPattern($file, $pattern) { - $pattern = '/laravel-(\d){4}-(\d){2}-(\d){2}.log/'; - - return ((bool) preg_match($pattern, $file, $matches)) === false; + return ((bool) preg_match("/{$pattern}/", $file, $matches)) === false; } }