Skip to content

Commit

Permalink
Works without logrotate
Browse files Browse the repository at this point in the history
  • Loading branch information
rap2hpoutre committed Nov 23, 2014
1 parent 10ed3d0 commit 0494736
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 31 deletions.
22 changes: 22 additions & 0 deletions src/Rap2hpoutre/LaravelLogViewer/LaravelLogViewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,25 @@ public static function all()
unset($trash);
}

$levels_classes = [
'debug' => 'info',
'info' => 'info',
'notice' => 'info',
'warning' => 'warning',
'error' => 'danger',
'critical' => 'danger',
'alert' => 'danger',
];
$levels_imgs = [
'debug' => 'info',
'info' => 'info',
'notice' => 'info',
'warning' => 'warning',
'error' => 'warning',
'critical' => 'warning',
'alert' => 'warning',
];

foreach ($headings as $h) {
for ($i=0, $j = count($h); $i < $j; $i++) {
foreach ($log_levels as $ll) {
Expand All @@ -38,8 +57,11 @@ public static function all()

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


$log[] = array(
'level' => $ll,
'level_class' => $levels_classes[$ll],
'level_img' => $levels_imgs[$ll],
'date' => $current[1],
'text' => $current[2],
'in_file' => isset($current[3]) ? $current[3] : null,
Expand Down
79 changes: 48 additions & 31 deletions src/views/log.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,53 +8,70 @@

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



<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<style>
body {
padding: 25px;
}
h1 {
font-size: 1.5em;
margin-top: 0px;
}
</style>
</head>
<body>
<div class="container-fluid">
<div class="container-fluid"">
<div class="row">
<div class="col-sm-3 col-md-2 sidebar">
<p>Todo</p>
<h1><span class="glyphicon glyphicon-calendar" aria-hidden="true"></span> Laravel Log Viewer</h1>
<p class="text-muted"><i>by Rap2h</i></p>
</div>
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
<div class="table-responsive">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Level</th>
<th>Date</th>
<th>Content</th>
</tr>
</thead>
<tbody>
@foreach($logs as $log)
<tr>
<td>{{{$log['level']}}}</td>
<td>{{{$log['date']}}}</td>
<td>
{{{$log['text']}}}
@if (isset($log['in_file']))
<br />{{{$log['in_file']}}}
@endif
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
<div class="col-sm-9 col-md-10">
<table class="table table-striped">
<thead>
<tr>
<th>Level</th>
<th>Date</th>
<th>Content</th>
</tr>
</thead>
<tbody>
@foreach($logs as $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>{{{$log['date']}}}</td>
<td>
{{{$log['text']}}}
@if (isset($log['in_file']))
<br />{{{$log['in_file']}}}
@endif
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>

<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="//cdn.datatables.net/1.10.4/js/jquery.dataTables.min.js"></script>
<script src="//cdn.datatables.net/plug-ins/9dcbecd42ad/integration/bootstrap/3/dataTables.bootstrap.js"></script>
<script>
$(document).ready(function(){
$('table').DataTable({
"order": [ 1, 'desc' ]
});
});
</script>
</body>
</html>

0 comments on commit 0494736

Please sign in to comment.