From 2478de6b98f731ed1caa4786c07471de50154133 Mon Sep 17 00:00:00 2001 From: Ross Date: Wed, 29 Apr 2026 22:37:13 +0100 Subject: [PATCH] feat: Enhance logs view with support for displaying all entries and improved pagination Co-authored-by: Copilot --- rad/views.py | 12 +++++++-- templates/logs_viewer.html | 52 ++++++++++++++++++-------------------- 2 files changed, 34 insertions(+), 30 deletions(-) diff --git a/rad/views.py b/rad/views.py index 2b2a3f89..6b1bd456 100644 --- a/rad/views.py +++ b/rad/views.py @@ -243,10 +243,12 @@ def logs_view(request): Scope: superusers only. Functionality: reads log.txt, displays entries with optional text search filter. + Supports ?all=1 to show all entries without pagination limit. """ log_file_path = os.path.join(settings.BASE_DIR, "log.txt") entries = [] search_query = request.GET.get("q", "").strip() + show_all = request.GET.get("all") == "1" if os.path.exists(log_file_path): try: @@ -267,14 +269,20 @@ def logs_view(request): else: entries = [f"Log file not found at {log_file_path}"] + total = len(entries) + limit = None if show_all else 500 + displayed_entries = entries[:limit] if limit else entries + return render( request, "logs_viewer.html", { - "entries": entries[:500], - "total_entries": len(entries), + "entries": displayed_entries, + "total_entries": total, "search_query": search_query, "log_file_path": log_file_path, + "show_all": show_all, + "limit": limit, }, ) diff --git a/templates/logs_viewer.html b/templates/logs_viewer.html index 15c257d9..50ac74cb 100644 --- a/templates/logs_viewer.html +++ b/templates/logs_viewer.html @@ -11,7 +11,11 @@
+ {% if show_all %} + Viewing all {{ total_entries }} entries + {% else %} Showing {{ entries|length }}/{{ total_entries }} entries + {% endif %}
@@ -19,7 +23,7 @@
-
+
Clear {% endif %}
+
+ {% if show_all %} + Show recent only + {% else %} + View all logs + {% endif %} +
{% if entries %}
-
-
- - - {% for entry in entries %} - - - - - {% endfor %} - -
- {{ forloop.counter }} - - {% if 'ERROR' in entry %} - ERROR - {% elif 'WARNING' in entry or 'WARN' in entry %} - WARN - {% elif 'DEBUG' in entry %} - DEBUG - {% elif 'INFO' in entry %} - INFO - {% endif %} - {{ entry }} -
-
+
+
{% for entry in entries %}
+{{ entry }}
+{% endfor %}
- Showing most recent entries first. Filtered display limited to 500 entries. + {% if show_all %} + Displaying all {{ total_entries }} log entries (newest first). + {% else %} + Displaying most recent 500 entries (newest first). + {% if total_entries > 500 %} + View all {{ total_entries }} entries. + {% endif %} + {% endif %} {% if search_query %} Search found {{ entries|length }} matching entr{{ entries|length|pluralize:"y,ies" }}. {% endif %}