Skip to content

Commit

Permalink
Update somethings
Browse files Browse the repository at this point in the history
  • Loading branch information
rap2hpoutre committed Jan 2, 2015
1 parent 6d8bf82 commit 0a97363
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
19 changes: 14 additions & 5 deletions src/Rap2hpoutre/LaravelLogViewer/LaravelLogViewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class LaravelLogViewer
{

/**
* @var current file
* @var file
*/
private static $file;

Expand All @@ -27,6 +27,14 @@ public static function setFile($file)
}
}

/**
* @return file
*/
public static function getFileName()
{
return basename(self::$file);
}

/**
* @return array
*/
Expand All @@ -39,13 +47,14 @@ public static function all()

$pattern = '/\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\].*/';

if (self::$file) {
$file = File::get(self::$file);
} else {

if (!self::$file) {
$log_file = self::getFiles();
$file = File::get($log_file[0]);
self::$file = $log_file[0];
}

$file = File::get(self::$file);

preg_match_all($pattern, $file, $headings);

$log_data = preg_split($pattern, $file);
Expand Down
5 changes: 3 additions & 2 deletions src/controllers/LogViewerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ public function index()

return View::make('laravel-log-viewer::log', [
'logs' => $logs,
'files' => LaravelLogViewer::getFiles(true)]
);
'files' => LaravelLogViewer::getFiles(true),
'current_file' => LaravelLogViewer::getFileName()
]);
}

}
15 changes: 11 additions & 4 deletions src/views/log.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
.text {
word-break: break-all;
}
a.llv-active {
z-index: 2;
background-color: #f5f5f5;
border-color: #777;
}
</style>
</head>
<body>
Expand All @@ -45,11 +50,13 @@
<p class="text-muted"><i>by Rap2h</i></p>
<div class="list-group">
@foreach($files as $file)
<a href="/{{{ Route::getCurrentRoute()->getPath() }}}?l={{{ Crypt::encrypt($file) }}}" class="list-group-item">{{$file}}</a>
<a href="{{{ Request::url() }}}/?l={{{ Crypt::encrypt($file) }}}" class="list-group-item @if ($current_file == $file) llv-active @endif">
{{$file}}
</a>
@endforeach
</div>
</div>
<div class="col-sm-9 col-md-10">
<div class="col-sm-9 col-md-10 table-container">
<table class="table table-striped">
<thead>
<tr>
Expand All @@ -72,7 +79,7 @@
<br />{{{$log['in_file']}}}
@endif
@if ($log['stack'])
<div class="stack" id="stack{{{$key}}}" style="display: none;">{{nl2br($log['stack']);}}</div>
<div class="stack" id="stack{{{$key}}}" style="display: none;">{{ nl2br(e($log['stack'])) }}</div>
@endif
</td>
</tr>
Expand All @@ -91,7 +98,7 @@
$('table').DataTable({
"order": [ 1, 'desc' ]
});
$('.expand').click(function(){
$('.table-container').on('click', '.expand', function(){
$('#' + $(this).data('display')).toggle();
});
Expand Down

0 comments on commit 0a97363

Please sign in to comment.