Skip to content
This repository has been archived by the owner on Jun 23, 2020. It is now read-only.

Commit

Permalink
fix logs preg.
Browse files Browse the repository at this point in the history
  • Loading branch information
tanwencn committed Apr 27, 2020
1 parent dbfedd8 commit eb12824
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions resources/views/_log_views/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
</code>
</td>
<td>
@if(!empty(trim($val[5])))
@if(isset($val[5]) && !empty(trim($val[5])))
<button type="button" class="btn btn-xs btn-primary" data-toggle="modal"
data-target="#modal-default{{ $key }}"> View
</button>
Expand All @@ -134,7 +134,7 @@
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<pre><code>{{ $val[4].$val[5] }}</code></pre>
<pre><code>{{ $val[4].(isset($val[5])?$val[5]:"") }}</code></pre>
</div>
</div>
<!-- /.modal-content -->
Expand Down
8 changes: 4 additions & 4 deletions src/Http/Controllers/LogViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ protected function data(SplFileInfo $file)

while ($this->eof = $file->valid()) {
$line = $file->fgets() . "\n";
if ($once_rows > config('admin.laravel_logs.read_once_rows', 10000) && preg_match('/\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\].*/', $line)) {
if ($once_rows > config('admin.laravel_logs.read_once_rows', 10000) && preg_match('/\[\d{4}-\d{2}-\d{2}.*\].*/', $line)) {
if (!$this->isRefresh()) {
session(['log_view_line_last' => $this->rows_line]);
session(['log_view_line' => $file->key()-1]);
Expand All @@ -86,16 +86,16 @@ protected function data(SplFileInfo $file)
$once_rows++;
}

preg_match_all('/\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\].*/', $content, $headings);
$log_data = preg_split('/\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\].*/', $content, null);
preg_match_all('/\[\d{4}-\d{2}-\d{2}.*\].*/', $content, $headings);
$log_data = preg_split('/\[\d{4}-\d{2}-\d{2}.*\].*/', $content, null);
if ($log_data[0] < 1)
array_shift($log_data);

$headings = array_shift($headings);

$results = [];
foreach ($headings as $key => $heading){
preg_match('/^\[(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})\] (.+?)\.(.+?): (.*)/', $heading, $results[$key]);
preg_match('/^\[(\d{4}-\d{2}-\d{2}.+\d)\] (.+?)\.(.+?): (.*)/', trim($heading), $results[$key]);
array_push($results[$key], $log_data[$key]);
}

Expand Down

0 comments on commit eb12824

Please sign in to comment.