v0.2.1 add Logging

This commit is contained in:
Björn Nehlsen
2026-08-16 00:38:25 +02:00
parent 8ad924b6ba
commit 212e63c4e4
7 changed files with 763 additions and 9 deletions
+105
View File
@@ -0,0 +1,105 @@
{% extends "base_admin.html" %}
{% block title %}BackItUp - Logs{% endblock %}
{% block content %}
<div class="card">
<h2>System Logs</h2>
<p>Alle wichtigen Laufzeit-, Fehler- und Audit-Ereignisse aus der Datei <strong>data/log.db</strong>.</p>
</div>
<div class="grid">
<div class="card">
<h3>24h Statistik</h3>
<p>DEBUG: {{ level_stats.DEBUG }}</p>
<p>INFO: {{ level_stats.INFO }}</p>
<p>WARNING: {{ level_stats.WARNING }}</p>
<p>ERROR: {{ level_stats.ERROR }}</p>
<p>CRITICAL: {{ level_stats.CRITICAL }}</p>
</div>
<div class="card">
<h3>Logs filtern</h3>
<form method="get" action="{{ url_for('logs_view') }}">
<div class="row">
<div>
<label for="level">Level</label>
<select id="level" name="level">
<option value="" {% if not filters.level %}selected{% endif %}>Alle</option>
<option value="DEBUG" {% if filters.level == 'DEBUG' %}selected{% endif %}>DEBUG</option>
<option value="INFO" {% if filters.level == 'INFO' %}selected{% endif %}>INFO</option>
<option value="WARNING" {% if filters.level == 'WARNING' %}selected{% endif %}>WARNING</option>
<option value="ERROR" {% if filters.level == 'ERROR' %}selected{% endif %}>ERROR</option>
<option value="CRITICAL" {% if filters.level == 'CRITICAL' %}selected{% endif %}>CRITICAL</option>
</select>
</div>
<div>
<label for="category">Kategorie</label>
<select id="category" name="category">
<option value="" {% if not filters.category %}selected{% endif %}>Alle</option>
{% for cat in categories %}
<option value="{{ cat }}" {% if filters.category == cat %}selected{% endif %}>{{ cat }}</option>
{% endfor %}
</select>
</div>
</div>
<div class="row">
<div>
<label for="q">Suche</label>
<input id="q" name="q" type="text" value="{{ filters.q }}" placeholder="Text in Message, Event, User oder Details">
</div>
<div>
<label for="limit">Limit</label>
<input id="limit" name="limit" type="number" min="1" max="1000" value="{{ filters.limit }}">
</div>
</div>
<button type="submit" class="btn">Filter anwenden</button>
</form>
</div>
</div>
<div class="card">
<form method="post" action="{{ url_for('logs_clear') }}" onsubmit="return confirm('Alle Logs wirklich löschen?');" style="margin-bottom: 10px;">
<button type="submit" class="btn" style="background: linear-gradient(135deg, #b9382f, #d24d3f);">Alle Logs löschen</button>
</form>
<div style="overflow:auto; border:1px solid var(--line); border-radius:12px;">
<table class="users-table">
<thead>
<tr>
<th>Zeit</th>
<th>Level</th>
<th>Kategorie</th>
<th>Event</th>
<th>Benutzer</th>
<th>Backup</th>
<th>Nachricht</th>
<th>Request</th>
<th>Status</th>
<th>Details</th>
</tr>
</thead>
<tbody>
{% for item in logs %}
<tr>
<td>{{ item.created_at }}</td>
<td><span class="badge">{{ item.level }}</span></td>
<td>{{ item.category }}</td>
<td>{{ item.event }}</td>
<td>{{ item.username or '-' }}</td>
<td>{{ item.backup_id or '-' }}</td>
<td>{{ item.message }}</td>
<td>{{ item.request_method or '' }} {{ item.request_path or '' }}</td>
<td>{{ item.status_code or '-' }}</td>
<td>{{ detail_compactor(item.details, 220) }}</td>
</tr>
{% else %}
<tr>
<td colspan="10">Keine Logs gefunden.</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endblock %}