diff --git a/resources/views/logs.blade.php b/resources/views/logs.blade.php index 58b5c1b..c9ba9a6 100644 --- a/resources/views/logs.blade.php +++ b/resources/views/logs.blade.php @@ -115,7 +115,7 @@ function fetch() { {{ $log['level'] }} {{ $log['env'] }} - {{ $log['time'] }} + {{ $log['time'] }} {{ $log['info'] }} @if(!empty($log['trace'])) @@ -181,4 +181,4 @@ function fetch() { - \ No newline at end of file + diff --git a/src/LogViewer.php b/src/LogViewer.php index 96eef0c..78a5fd5 100644 --- a/src/LogViewer.php +++ b/src/LogViewer.php @@ -30,7 +30,10 @@ class LogViewer extends Extension * * @var array */ - protected $pageOffset = []; + protected $pageOffset = [ + 'start' => 0, + 'end' => 0, + ]; /** * @var array @@ -169,6 +172,9 @@ public function getNextPageUrl() */ public function fetch($seek = 0, $lines = 20, $buffer = 4096) { + if (!is_file($this->filePath)) { + return $this->parseLog(""); + } $f = fopen($this->filePath, 'rb'); if ($seek) { @@ -317,7 +323,7 @@ protected function renderTableRow($log) */ protected function parseLog($raw) { - $logs = preg_split('/\[(\d{4}(?:-\d{2}){2} \d{2}(?::\d{2}){2})\] (\w+)\.(\w+):((?:(?!{"exception").)*)?/', trim($raw), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); + $logs = preg_split('/\[(\d{4}(?:-\d{2}){2} \d{2}(?::\d{2}){2}\.\d+|\d{4}(?:-\d{2}){2} \d{2}(?::\d{2}){2})\] (\w+)\.(\w+):((?:(?!{"exception").)*)?/', trim($raw), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); foreach ($logs as $index => $log) { if (preg_match('/^\d{4}/', $log)) {