feat: Add logs view for superusers to display and search production logs
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container-fluid py-4">
|
||||
<div class="d-flex justify-content-between align-items-start gap-3 mb-4">
|
||||
<div>
|
||||
<h2 class="mb-1">Production Logs</h2>
|
||||
<p class="text-muted small mb-0">
|
||||
Real-time log monitoring from <code>{{ log_file_path }}</code>
|
||||
</p>
|
||||
</div>
|
||||
<div class="text-end">
|
||||
<span class="badge bg-secondary rounded-pill px-3 py-2">
|
||||
Showing {{ entries|length }}/{{ total_entries }} entries
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card border-0 shadow-sm mb-4">
|
||||
<div class="card-body">
|
||||
<form method="get" class="row g-2">
|
||||
<div class="col-12 col-md-8">
|
||||
<input type="search"
|
||||
name="q"
|
||||
class="form-control"
|
||||
placeholder="Search logs by keyword (error, warning, etc)…"
|
||||
value="{{ search_query }}">
|
||||
</div>
|
||||
<div class="col-12 col-md-auto">
|
||||
<button type="submit" class="btn btn-primary">Search</button>
|
||||
{% if search_query %}
|
||||
<a href="{% url 'logs_view' %}" class="btn btn-outline-secondary ms-1">Clear</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if entries %}
|
||||
<div class="card border-0 shadow-sm">
|
||||
<div class="card-body p-0">
|
||||
<div style="max-height: 70vh; overflow-y: auto;">
|
||||
<table class="table table-sm table-striped mb-0" style="font-family: monospace; font-size: 0.875rem;">
|
||||
<tbody>
|
||||
{% for entry in entries %}
|
||||
<tr>
|
||||
<td class="text-muted align-top" style="width: 30px; white-space: nowrap;">
|
||||
{{ forloop.counter }}
|
||||
</td>
|
||||
<td style="word-break: break-all; white-space: pre-wrap;">
|
||||
{% if 'ERROR' in entry %}
|
||||
<span class="badge bg-danger me-1">ERROR</span>
|
||||
{% elif 'WARNING' in entry or 'WARN' in entry %}
|
||||
<span class="badge bg-warning me-1">WARN</span>
|
||||
{% elif 'DEBUG' in entry %}
|
||||
<span class="badge bg-secondary me-1">DEBUG</span>
|
||||
{% elif 'INFO' in entry %}
|
||||
<span class="badge bg-info me-1">INFO</span>
|
||||
{% endif %}
|
||||
{{ entry }}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="alert alert-secondary mt-3 small">
|
||||
<i class="bi bi-info-circle"></i>
|
||||
Showing most recent entries first. Filtered display limited to 500 entries.
|
||||
{% if search_query %}
|
||||
Search found {{ entries|length }} matching entr{{ entries|length|pluralize:"y,ies" }}.
|
||||
{% endif %}
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="alert alert-info">
|
||||
No log entries found.
|
||||
{% if search_query %}
|
||||
Try a different search term.
|
||||
{% else %}
|
||||
The log file may be empty or not yet created.
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user