diff --git a/src/runtime/logging.rs b/src/runtime/logging.rs index 40fee3e2aa9fc159f3b4e27ce10d9afc8643a3b9..cdbe2b3611125add0c82d5ce7da8990742b8f0a3 100644 --- a/src/runtime/logging.rs +++ b/src/runtime/logging.rs @@ -1,5 +1,11 @@ use super::*; +fn secs_since_unix_epoch() -> f64 { + std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .map(|dur| dur.as_secs_f64()) + .unwrap_or(0.) +} impl FileLogger { pub fn new(connector_id: ConnectorId, file: std::fs::File) -> Self { Self(connector_id, file) @@ -16,15 +22,16 @@ impl Logger for DummyLogger { None } } + impl Logger for VecLogger { fn line_writer(&mut self) -> Option<&mut dyn std::io::Write> { - let _ = write!(&mut self.1, "CID({}) at {:?} ", self.0, Instant::now()); + let _ = write!(&mut self.1, "CID({}) at {:.6} ", self.0, secs_since_unix_epoch()); Some(self) } } impl Logger for FileLogger { fn line_writer(&mut self) -> Option<&mut dyn std::io::Write> { - let _ = write!(&mut self.1, "CID({}) at {:?} ", self.0, Instant::now()); + let _ = write!(&mut self.1, "CID({}) at {:.6} ", self.0, secs_since_unix_epoch()); Some(&mut self.1) } }