Skip to content

Commit

Permalink
Merge pull request #70 from mallardduck/master
Browse files Browse the repository at this point in the history
Add Log context to table
  • Loading branch information
rap2hpoutre authored Jul 2, 2016
2 parents cc955ff + fa69c7f commit 32ab227
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Rap2hpoutre/LaravelLogViewer/LaravelLogViewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,18 @@ public static function all()
foreach ($log_levels as $level_key => $level_value) {
if (strpos(strtolower($h[$i]), '.' . $level_value)) {

preg_match('/^\[(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})\].*?\.' . $level_key . ': (.*?)( in .*?:[0-9]+)?$/', $h[$i], $current);
preg_match('/^\[(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})\].*?(\w+)\.' . $level_key . ': (.*?)( in .*?:[0-9]+)?$/', $h[$i], $current);

if (!isset($current[2])) continue;
if (!isset($current[3])) continue;

$log[] = array(
'context' => $current[2],
'level' => $level_value,
'level_class' => self::$levels_classes[$level_value],
'level_img' => self::$levels_imgs[$level_value],
'date' => $current[1],
'text' => $current[2],
'in_file' => isset($current[3]) ? $current[3] : null,
'text' => $current[3],
'in_file' => isset($current[4]) ? $current[4] : null,
'stack' => preg_replace("/^\n*/", '', $log_data[$i])
);
}
Expand Down
2 changes: 2 additions & 0 deletions src/views/log.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
<thead>
<tr>
<th>Level</th>
<th>Context</th>
<th>Date</th>
<th>Content</th>
</tr>
Expand All @@ -75,6 +76,7 @@
@foreach($logs as $key => $log)
<tr>
<td class="text-{{{$log['level_class']}}}"><span class="glyphicon glyphicon-{{{$log['level_img']}}}-sign" aria-hidden="true"></span> &nbsp;{{$log['level']}}</td>
<td class="text">{{$log['context']}}</td>
<td class="date">{{{$log['date']}}}</td>
<td class="text">
@if ($log['stack']) <a class="pull-right expand btn btn-default btn-xs" data-display="stack{{{$key}}}"><span class="glyphicon glyphicon-search"></span></a>@endif
Expand Down

0 comments on commit 32ab227

Please sign in to comment.