Skip to content

Commit 0494736

Browse files
committed
Works without logrotate
1 parent 10ed3d0 commit 0494736

File tree

2 files changed

+70
-31
lines changed

2 files changed

+70
-31
lines changed

src/Rap2hpoutre/LaravelLogViewer/LaravelLogViewer.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,25 @@ public static function all()
2929
unset($trash);
3030
}
3131

32+
$levels_classes = [
33+
'debug' => 'info',
34+
'info' => 'info',
35+
'notice' => 'info',
36+
'warning' => 'warning',
37+
'error' => 'danger',
38+
'critical' => 'danger',
39+
'alert' => 'danger',
40+
];
41+
$levels_imgs = [
42+
'debug' => 'info',
43+
'info' => 'info',
44+
'notice' => 'info',
45+
'warning' => 'warning',
46+
'error' => 'warning',
47+
'critical' => 'warning',
48+
'alert' => 'warning',
49+
];
50+
3251
foreach ($headings as $h) {
3352
for ($i=0, $j = count($h); $i < $j; $i++) {
3453
foreach ($log_levels as $ll) {
@@ -38,8 +57,11 @@ public static function all()
3857

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

60+
4161
$log[] = array(
4262
'level' => $ll,
63+
'level_class' => $levels_classes[$ll],
64+
'level_img' => $levels_imgs[$ll],
4365
'date' => $current[1],
4466
'text' => $current[2],
4567
'in_file' => isset($current[3]) ? $current[3] : null,

src/views/log.blade.php

Lines changed: 48 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,53 +8,70 @@
88

99
<!-- Bootstrap -->
1010
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
11+
<link rel="stylesheet" href="//cdn.datatables.net/plug-ins/9dcbecd42ad/integration/bootstrap/3/dataTables.bootstrap.css">
12+
13+
1114

1215
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
1316
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
1417
<!--[if lt IE 9]>
1518
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
1619
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
1720
<![endif]-->
21+
<style>
22+
body {
23+
padding: 25px;
24+
}
25+
h1 {
26+
font-size: 1.5em;
27+
margin-top: 0px;
28+
}
29+
</style>
1830
</head>
1931
<body>
20-
<div class="container-fluid">
32+
<div class="container-fluid"">
2133
<div class="row">
2234
<div class="col-sm-3 col-md-2 sidebar">
23-
<p>Todo</p>
35+
<h1><span class="glyphicon glyphicon-calendar" aria-hidden="true"></span> Laravel Log Viewer</h1>
36+
<p class="text-muted"><i>by Rap2h</i></p>
2437
</div>
25-
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
26-
<div class="table-responsive">
27-
<div class="table-responsive">
28-
<table class="table table-striped">
29-
<thead>
30-
<tr>
31-
<th>Level</th>
32-
<th>Date</th>
33-
<th>Content</th>
34-
</tr>
35-
</thead>
36-
<tbody>
37-
@foreach($logs as $log)
38-
<tr>
39-
<td>{{{$log['level']}}}</td>
40-
<td>{{{$log['date']}}}</td>
41-
<td>
42-
{{{$log['text']}}}
43-
@if (isset($log['in_file']))
44-
<br />{{{$log['in_file']}}}
45-
@endif
46-
</td>
47-
</tr>
48-
@endforeach
49-
</tbody>
50-
</table>
51-
</div>
52-
</div>
38+
<div class="col-sm-9 col-md-10">
39+
<table class="table table-striped">
40+
<thead>
41+
<tr>
42+
<th>Level</th>
43+
<th>Date</th>
44+
<th>Content</th>
45+
</tr>
46+
</thead>
47+
<tbody>
48+
@foreach($logs as $log)
49+
<tr>
50+
<td class="text-{{{$log['level_class']}}}"><span class="glyphicon glyphicon-{{{$log['level_img']}}}-sign" aria-hidden="true"></span> &nbsp;{{$log['level']}}</td>
51+
<td>{{{$log['date']}}}</td>
52+
<td>
53+
{{{$log['text']}}}
54+
@if (isset($log['in_file']))
55+
<br />{{{$log['in_file']}}}
56+
@endif
57+
</td>
58+
</tr>
59+
@endforeach
60+
</tbody>
61+
</table>
5362
</div>
5463
</div>
5564
</div>
56-
5765
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
5866
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
67+
<script src="//cdn.datatables.net/1.10.4/js/jquery.dataTables.min.js"></script>
68+
<script src="//cdn.datatables.net/plug-ins/9dcbecd42ad/integration/bootstrap/3/dataTables.bootstrap.js"></script>
69+
<script>
70+
$(document).ready(function(){
71+
$('table').DataTable({
72+
"order": [ 1, 'desc' ]
73+
});
74+
});
75+
</script>
5976
</body>
6077
</html>

0 commit comments

Comments
 (0)