Skip to content

Commit fa69c7f

Browse files
committed
Add context to table
1 parent cc955ff commit fa69c7f

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/Rap2hpoutre/LaravelLogViewer/LaravelLogViewer.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,17 +117,18 @@ public static function all()
117117
foreach ($log_levels as $level_key => $level_value) {
118118
if (strpos(strtolower($h[$i]), '.' . $level_value)) {
119119

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

122-
if (!isset($current[2])) continue;
122+
if (!isset($current[3])) continue;
123123

124124
$log[] = array(
125+
'context' => $current[2],
125126
'level' => $level_value,
126127
'level_class' => self::$levels_classes[$level_value],
127128
'level_img' => self::$levels_imgs[$level_value],
128129
'date' => $current[1],
129-
'text' => $current[2],
130-
'in_file' => isset($current[3]) ? $current[3] : null,
130+
'text' => $current[3],
131+
'in_file' => isset($current[4]) ? $current[4] : null,
131132
'stack' => preg_replace("/^\n*/", '', $log_data[$i])
132133
);
133134
}

src/views/log.blade.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
<thead>
6767
<tr>
6868
<th>Level</th>
69+
<th>Context</th>
6970
<th>Date</th>
7071
<th>Content</th>
7172
</tr>
@@ -75,6 +76,7 @@
7576
@foreach($logs as $key => $log)
7677
<tr>
7778
<td class="text-{{{$log['level_class']}}}"><span class="glyphicon glyphicon-{{{$log['level_img']}}}-sign" aria-hidden="true"></span> &nbsp;{{$log['level']}}</td>
79+
<td class="text">{{$log['context']}}</td>
7880
<td class="date">{{{$log['date']}}}</td>
7981
<td class="text">
8082
@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

0 commit comments

Comments
 (0)