diff --git a/daemon/src/main.rs b/daemon/src/main.rs index 3a9e8ed..b4ace33 100644 --- a/daemon/src/main.rs +++ b/daemon/src/main.rs @@ -40,6 +40,7 @@ use log::{error, info}; use qmdl_store::RecordingStoreError; use rayhunter::Device; use rayhunter::diag_device::DiagDevice; +use stats::get_log; use tokio::net::TcpListener; use tokio::select; use tokio::sync::mpsc::{self, Sender}; @@ -56,6 +57,7 @@ fn get_router() -> AppRouter { .route("/api/zip/{name}", get(get_zip)) .route("/api/system-stats", get(get_system_stats)) .route("/api/qmdl-manifest", get(get_qmdl_manifest)) + .route("/api/log", get(get_log)) .route("/api/start-recording", post(start_recording)) .route("/api/stop-recording", post(stop_recording)) .route("/api/delete-recording/{name}", post(delete_recording)) diff --git a/daemon/src/stats.rs b/daemon/src/stats.rs index 840dff5..5f5842c 100644 --- a/daemon/src/stats.rs +++ b/daemon/src/stats.rs @@ -168,3 +168,9 @@ pub async fn get_qmdl_manifest( current_entry, })) } + +pub async fn get_log() -> Result { + tokio::fs::read_to_string("/data/rayhunter/rayhunter.log") + .await + .map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, e.to_string())) +}