From 7c9ccf6df3853cfe75385f71a22aa3790c1e058e Mon Sep 17 00:00:00 2001 From: Nick Mowen Date: Mon, 5 Dec 2022 11:22:39 -0700 Subject: [PATCH] Return logs for services --- frigate/http.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/frigate/http.py b/frigate/http.py index f5e9eaa7a..2129241cf 100644 --- a/frigate/http.py +++ b/frigate/http.py @@ -1130,3 +1130,24 @@ def vainfo(): else "", } ) + + +@bp.route("/logs/", methods=["GET"]) +def logs(service: str): + log_locations = { + "frigate": "/dev/shm/logs/frigate/current", + "go2rtc": "/dev/shm/logs/go2rtc/current", + "nginx": "/dev/shm/logs/nginx/current", + } + service_location = log_locations.get(service) + + if not service: + return f"{service} is not a valid service", 404 + + try: + file = open(service_location, "r") + contents = file.read() + file.close() + return contents, 200 + except FileNotFoundError as e: + return f"Could not find log file: {e}", 500