From 3df3b9334874c3d6e59476998195327b827c8516 Mon Sep 17 00:00:00 2001 From: Chuck <33324927+ChuckBuilds@users.noreply.github.com> Date: Thu, 24 Jul 2025 16:13:35 -0500 Subject: [PATCH] added log viewer to web ui --- templates/index.html | 33 +++++++++++++++++++++++++++++++++ web_interface.py | 18 ++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/templates/index.html b/templates/index.html index 84e891b6..51c02961 100644 --- a/templates/index.html +++ b/templates/index.html @@ -404,6 +404,7 @@ + @@ -2300,6 +2301,15 @@ + +
+
+

System Logs

+

View logs for the LED matrix service. Useful for debugging.

+ +

+            
+
\ No newline at end of file diff --git a/web_interface.py b/web_interface.py index 2a51e688..bd82a25b 100644 --- a/web_interface.py +++ b/web_interface.py @@ -288,6 +288,24 @@ def run_action_route(): 'message': f'Error running action: {e}' }), 400 +@app.route('/get_logs', methods=['GET']) +def get_logs(): + try: + # Get logs from journalctl for the ledmatrix service + result = subprocess.run( + ['sudo', 'journalctl', '-u', 'ledmatrix.service', '-n', '500', '--no-pager'], + capture_output=True, text=True, check=True + ) + logs = result.stdout + return jsonify({'status': 'success', 'logs': logs}) + except subprocess.CalledProcessError as e: + # If the command fails, return the error + error_message = f"Error fetching logs: {e.stderr}" + return jsonify({'status': 'error', 'message': error_message}), 500 + except Exception as e: + # Handle other potential exceptions + return jsonify({'status': 'error', 'message': str(e)}), 500 + @app.route('/save_raw_json', methods=['POST']) def save_raw_json_route(): try: