refactor: replace systemd logger with env_logger

Co-authored-by: aider (gemini/gemini-2.5-pro-preview-05-06) <aider@aider.chat>
This commit is contained in:
Chaos Rogers 2025-07-21 20:52:55 +01:00
parent cd737b895e
commit ec132a2840
2 changed files with 7 additions and 14 deletions

View file

@ -18,7 +18,5 @@ actix-files = "0.6"
tokio = { version = "1", features = ["full"] } tokio = { version = "1", features = ["full"] }
clap = { version = "4.4", features = ["derive"] } clap = { version = "4.4", features = ["derive"] }
log = "0.4" log = "0.4"
env_logger = "0.11"
[target.'cfg(target_os = "linux")'.dependencies]
systemd = { version = "0.10", features = ["journal", "vendored"] }

View file

@ -13,6 +13,7 @@ use crate::serial_input::start_serial_thread;
use crate::sync_logic::LtcState; use crate::sync_logic::LtcState;
use crate::ui::start_ui; use crate::ui::start_ui;
use clap::Parser; use clap::Parser;
use env_logger;
use std::{ use std::{
fs, fs,
@ -102,17 +103,11 @@ async fn main() {
start_ui(ui_state, port, config_clone); start_ui(ui_state, port, config_clone);
}); });
} else { } else {
println!("🚀 Starting TimeTurner daemon..."); // In daemon mode, we initialize env_logger.
#[cfg(target_os = "linux")] // This will log to stdout, and the systemd service will capture it.
{ // The RUST_LOG env var controls the log level (e.g., RUST_LOG=info).
systemd::journal::init().unwrap(); env_logger::init();
log::set_max_level(log::LevelFilter::Info); log::info!("🚀 Starting TimeTurner daemon...");
log::info!("TimeTurner daemon started. API server is running.");
}
#[cfg(not(target_os = "linux"))]
{
println!("Daemon mode started. API server is running. Logging to system journal is only supported on Linux.");
}
} }
// 6⃣ Set up a LocalSet for the API server and main loop // 6⃣ Set up a LocalSet for the API server and main loop