cli: Gracefully handle failure to link log file

Not linking `node.log` is not ideal, but also not a critical failure.
It's better to swallow that instead of crashing.
This commit is contained in:
Lorenz Leutgeb
2025-08-15 10:13:51 +01:00
committed by Fintan Halpenny
parent de78cf7874
commit ed5b2659c8
+11 -1
View File
@@ -153,11 +153,21 @@ impl Rotate {
log::warn!(target: "cli", "Failed to remove current log file: {err}");
}
}
let log = OpenOptions::new()
.write(true)
.create_new(true)
.open(&self.next)?;
fs::hard_link(&self.next, &self.link)?;
if let Err(err) = fs::hard_link(&self.next, &self.link) {
log::warn!(
target: "cli",
"Failed to create hard link from {} to {}: {err}",
self.next.display(),
self.link.display()
);
}
Ok(Rotated {
path: self.next,
log,