fix(logging): use stable server log paths

This commit is contained in:
Bryan Helmkamp 2026-04-06 16:18:13 -04:00
parent 7f9b832040
commit 5abf775cf5
3 changed files with 6 additions and 5 deletions

View file

@ -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);

View file

@ -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();

View file

@ -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")
);
}