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:
parent
de78cf7874
commit
ed5b2659c8
|
|
@ -153,11 +153,21 @@ impl Rotate {
|
||||||
log::warn!(target: "cli", "Failed to remove current log file: {err}");
|
log::warn!(target: "cli", "Failed to remove current log file: {err}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let log = OpenOptions::new()
|
let log = OpenOptions::new()
|
||||||
.write(true)
|
.write(true)
|
||||||
.create_new(true)
|
.create_new(true)
|
||||||
.open(&self.next)?;
|
.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 {
|
Ok(Rotated {
|
||||||
path: self.next,
|
path: self.next,
|
||||||
log,
|
log,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue