forked from Github/frigate
Logs in UI (#4562)
* Log all services to RAM * Gracefully handle shutdown * Add logs route * Remove tail * Return logs for services * Display log chooser with copy button * show logs for specific services * Clean up settings logs * Add copy functionality to logs * Add copy functionality to logs * Fix merge * Set archive count to 0 Co-authored-by: Felipe Santos <felipecassiors@gmail.com>
This commit is contained in:
@@ -1142,3 +1142,24 @@ def vainfo():
|
||||
else "",
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@bp.route("/logs/<service>", 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
|
||||
|
||||
Reference in New Issue
Block a user