From 5abf775cf5269b599d55e036301b261ebe0df5b6 Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Mon, 6 Apr 2026 16:18:13 -0400 Subject: [PATCH] fix(logging): use stable server log paths --- lib/crates/fabro-cli/src/commands/server/start.rs | 3 +++ lib/crates/fabro-cli/src/logging.rs | 4 +--- lib/crates/fabro-config/src/storage.rs | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/crates/fabro-cli/src/commands/server/start.rs b/lib/crates/fabro-cli/src/commands/server/start.rs index e95883b12..59b8ae2b1 100644 --- a/lib/crates/fabro-cli/src/commands/server/start.rs +++ b/lib/crates/fabro-cli/src/commands/server/start.rs @@ -172,6 +172,9 @@ fn execute_daemon( // Rotate logs let server_state = Storage::new(storage_dir).server_state(); let log_path = server_state.log_path(); + if let Some(parent) = log_path.parent() { + std::fs::create_dir_all(parent)?; + } let prev_path = log_path.with_extension("log.prev"); let _ = std::fs::rename(&log_path, &prev_path); diff --git a/lib/crates/fabro-cli/src/logging.rs b/lib/crates/fabro-cli/src/logging.rs index 1de193dae..59b7f9ca6 100644 --- a/lib/crates/fabro-cli/src/logging.rs +++ b/lib/crates/fabro-cli/src/logging.rs @@ -21,9 +21,7 @@ pub(crate) fn init_tracing( std::fs::create_dir_all(&log_dir) .with_context(|| format!("Failed to create log directory: {}", log_dir.display()))?; - let filename = chrono::Local::now() - .format(&format!("{log_prefix}-%Y-%m-%d.log")) - .to_string(); + let filename = format!("{log_prefix}.log"); let file_appender = rolling::never(&log_dir, &filename); let run_log_writer = run_log::init(); diff --git a/lib/crates/fabro-config/src/storage.rs b/lib/crates/fabro-config/src/storage.rs index 2838031cf..f12aa4ff0 100644 --- a/lib/crates/fabro-config/src/storage.rs +++ b/lib/crates/fabro-config/src/storage.rs @@ -78,7 +78,7 @@ impl ServerState { #[must_use] pub fn log_path(&self) -> PathBuf { - self.root.join("server.log") + self.root.join("logs").join("server.log") } } @@ -203,7 +203,7 @@ mod tests { ); assert_eq!( storage.server_state().log_path(), - std::path::Path::new("/tmp/fabro-data/server.log") + std::path::Path::new("/tmp/fabro-data/logs/server.log") ); }