add system log viewer
This commit is contained in:
48
templates/admin/system_logs/index.html.twig
Normal file
48
templates/admin/system_logs/index.html.twig
Normal file
@@ -0,0 +1,48 @@
|
||||
{% extends 'admin/base.html.twig' %}
|
||||
|
||||
{% block title %}System Logs{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h1 class="h3 mb-0">System Logs</h1>
|
||||
</div>
|
||||
|
||||
<div class="card bg-dark border-secondary">
|
||||
<div class="card-body p-0">
|
||||
<table class="table table-dark table-striped mb-0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Datei</th>
|
||||
<th>Größe</th>
|
||||
<th>Letzte Änderung</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for file in files %}
|
||||
<tr>
|
||||
<td>{% set date = file.name == 'system.log'
|
||||
? 'current'
|
||||
: file.name|replace({'system-':'','\.log':''}) %}
|
||||
{{ file.name }}</td>
|
||||
<td>{{ (file.size / 1024)|number_format(2) }} KB</td>
|
||||
<td>{{ file.mtime|date('Y-m-d H:i:s') }}</td>
|
||||
<td>
|
||||
<a href="{{ path('admin_system_logs_view', { date: date }) }}"
|
||||
class="btn btn-sm btn-outline-info">
|
||||
Anzeigen
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="4" class="text-center text-muted p-3">
|
||||
Keine Logdateien gefunden.
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
61
templates/admin/system_logs/view.html.twig
Normal file
61
templates/admin/system_logs/view.html.twig
Normal file
@@ -0,0 +1,61 @@
|
||||
{% extends 'admin/base.html.twig' %}
|
||||
|
||||
{% block title %}System Log - {{ filename }}{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center mb-3">
|
||||
<h1 class="h5 mb-0">{{ filename }}</h1>
|
||||
|
||||
<input type="text"
|
||||
id="logSearch"
|
||||
class="form-control form-control-sm"
|
||||
placeholder="Search..."
|
||||
style="max-width:300px;">
|
||||
</div>
|
||||
|
||||
<div class="card bg-black border-secondary">
|
||||
<div class="card-body p-0">
|
||||
<pre id="logContent"
|
||||
style="margin:0;padding:15px;background:#000;color:#00ff88;
|
||||
font-size:12px;line-height:1.4;
|
||||
max-height:75vh;overflow:auto;white-space:pre-wrap;">
|
||||
{{ content }}
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
(function () {
|
||||
|
||||
const input = document.getElementById('logSearch');
|
||||
const logElement = document.getElementById('logContent');
|
||||
|
||||
const originalText = logElement.textContent;
|
||||
|
||||
function escapeRegExp(string) {
|
||||
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||
}
|
||||
|
||||
function highlight(term) {
|
||||
if (!term) {
|
||||
logElement.innerHTML = originalText;
|
||||
return;
|
||||
}
|
||||
|
||||
const safeTerm = escapeRegExp(term);
|
||||
const regex = new RegExp('(' + safeTerm + ')', 'gi');
|
||||
|
||||
logElement.innerHTML = originalText.replace(regex, function(match) {
|
||||
return '<span style="background:#ffcc00;color:#000;">' + match + '</span>';
|
||||
});
|
||||
}
|
||||
|
||||
input.addEventListener('input', function () {
|
||||
highlight(this.value.trim());
|
||||
});
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user