diff --git a/src/Rap2hpoutre/LaravelLogViewer/LaravelLogViewer.php b/src/Rap2hpoutre/LaravelLogViewer/LaravelLogViewer.php index fb37ea4..bb16805 100644 --- a/src/Rap2hpoutre/LaravelLogViewer/LaravelLogViewer.php +++ b/src/Rap2hpoutre/LaravelLogViewer/LaravelLogViewer.php @@ -67,8 +67,16 @@ public static function all() $log_levels = self::getLogLevels(); $pattern = '/\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\].*/'; + + if (!self::$file) { + $log_file = self::getFiles(); + if(!count($log_file)) { + return []; + } + self::$file = $log_file[0]; + } - $file = self::getCurrentFile(); + $file = File::get(self::$file); preg_match_all($pattern, $file, $headings); @@ -122,22 +130,6 @@ public static function getFiles($basename = false) return $files; } - /** - * @return array - */ - private static function getCurrentFile() - { - if (!self::$file) { - $log_file = self::getFiles(); - if(!count($log_file)) { - return []; - } - self::$file = $log_file[0]; - } - - return File::get(self::$file); - } - /** * @return array */