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"] }
clap = { version = "4.4", features = ["derive"] }
log = "0.4"
[target.'cfg(target_os = "linux")'.dependencies]
systemd = { version = "0.10", features = ["journal", "vendored"] }
env_logger = "0.11"

View file

@ -13,6 +13,7 @@ use crate::serial_input::start_serial_thread;
use crate::sync_logic::LtcState;
use crate::ui::start_ui;
use clap::Parser;
use env_logger;
use std::{
fs,
@ -102,17 +103,11 @@ async fn main() {
start_ui(ui_state, port, config_clone);
});
} else {
println!("🚀 Starting TimeTurner daemon...");
#[cfg(target_os = "linux")]
{
systemd::journal::init().unwrap();
log::set_max_level(log::LevelFilter::Info);
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.");
}
// In daemon mode, we initialize env_logger.
// 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).
env_logger::init();
log::info!("🚀 Starting TimeTurner daemon...");
}
// 6⃣ Set up a LocalSet for the API server and main loop