mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-08-28 05:27:41 +00:00
fix(logging): use stable server log paths
This commit is contained in:
parent
7f9b832040
commit
5abf775cf5
3 changed files with 6 additions and 5 deletions
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue