diff --git a/src/Rap2hpoutre/LaravelLogViewer/LaravelLogViewer.php b/src/Rap2hpoutre/LaravelLogViewer/LaravelLogViewer.php
index 63e7c8b..f003312 100644
--- a/src/Rap2hpoutre/LaravelLogViewer/LaravelLogViewer.php
+++ b/src/Rap2hpoutre/LaravelLogViewer/LaravelLogViewer.php
@@ -231,4 +231,12 @@ public function getFiles($basename = false, $folder = '')
}
return array_values($files);
}
+
+ /**
+ * @return Level
+ */
+ public function getLevel()
+ {
+ return $this->level;
+ }
}
diff --git a/src/controllers/LogViewerController.php b/src/controllers/LogViewerController.php
index 9dbeaf4..24eb228 100644
--- a/src/controllers/LogViewerController.php
+++ b/src/controllers/LogViewerController.php
@@ -61,6 +61,7 @@ public function index()
'files' => $this->log_viewer->getFiles(true),
'current_file' => $this->log_viewer->getFileName(),
'standardFormat' => true,
+ 'levels' => $this->log_viewer->getLevel()->all(),
];
if ($this->request->wantsJson()) {
diff --git a/src/views/log.blade.php b/src/views/log.blade.php
index 4ac6a26..b232bf9 100644
--- a/src/views/log.blade.php
+++ b/src/views/log.blade.php
@@ -20,16 +20,16 @@
}
#table-log {
- font-size: 0.85rem;
+ font-size: 0.85rem;
}
.sidebar {
- font-size: 0.85rem;
- line-height: 1;
+ font-size: 0.85rem;
+ line-height: 1;
}
.btn {
- font-size: 0.7rem;
+ font-size: 0.7rem;
}
.stack {
@@ -62,10 +62,21 @@
height: 80vh;
overflow: hidden auto;
}
+
.nowrap {
white-space: nowrap;
}
+ .level svg {
+ margin-right: 5px;
+ }
+
+ .level-select select {
+ display: inline-block;
+ margin-left: 5px;
+ width: auto;
+ }
+
@@ -125,7 +136,7 @@ class="list-group-item @if ($current_file == $file) llv-active @endif">
@if ($standardFormat)
- {{$log['level']}}
+ {{$log['level']}}
|
{{$log['context']}} |
@endif
@@ -195,8 +206,9 @@ class="float-right expand btn btn-outline-dark btn-sm mb-2 ml-2"
$('.table-container tr').on('click', function () {
$('#' + $(this).data('display')).toggle();
});
- $('#table-log').DataTable({
- "order": [$('#table-log').data('orderingIndex'), 'desc'],
+
+ var options = {
+ "order": [$("#table-log").data("orderingIndex"), "desc"],
"stateSave": true,
"stateSaveCallback": function (settings, data) {
window.localStorage.setItem("datatable", JSON.stringify(data));
@@ -205,11 +217,48 @@ class="float-right expand btn btn-outline-dark btn-sm mb-2 ml-2"
var data = JSON.parse(window.localStorage.getItem("datatable"));
if (data) data.start = 0;
return data;
- }
- });
- $('#delete-log, #clean-log, #delete-all-log').click(function () {
- return confirm('Are you sure?');
+ },
+ };
+
+ @if ($standardFormat)
+ options.dom = "<'row'<'col-sm-4'l><'level-select col-sm-4'><'col-sm-4'f>><'row'<'col-sm-12'tr>><'row'<'col-sm-5'i><'col-sm-7'p>>";
+ @endif
+
+ var table = $("#table-log").DataTable(options);
+
+ $("#delete-log, #clean-log, #delete-all-log").click(function () {
+ return confirm("Are you sure?");
});
+
+ {{-- Add a level select filter --}}
+ @if ($standardFormat)
+ var levels = @json($levels);
+
+ var logSelect = "";
+
+ $("div.level-select").html(logSelect);
+
+ // Redraw the table whenever the level select changes
+ $("#level").change(function () {
+ table.draw();
+ });
+
+ $.fn.dataTable.ext.search.push(
+ function (settings, data) {
+ var level = $("#level").val();
+
+ return !level || data[0] === level;
+ },
+ );
+ @endif
});