tweak duration formatting in logs
This commit is contained in:
parent
84adeddec6
commit
8bc9126264
1 changed files with 4 additions and 2 deletions
|
@ -89,15 +89,17 @@ impl fmt::Display for AlertStatus {
|
|||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let days = |d: Duration| d.as_secs() / (3600 * 24);
|
||||
let hours = |d: Duration| (d.as_secs() / 3600) % 24;
|
||||
let minutes = |d: Duration| (d.as_secs() / 60) % 60;
|
||||
write!(
|
||||
f,
|
||||
"{}: inactivity: {} days, {} hours, last_alert: {}",
|
||||
"{}: inactivity: {}d{}h{}m, last_alert: {}",
|
||||
(if self.alert { "ALERT" } else { "no alert" }),
|
||||
days(self.inactivity),
|
||||
hours(self.inactivity),
|
||||
minutes(self.inactivity),
|
||||
match self.last_alert {
|
||||
None => "none".to_owned(),
|
||||
Some(d) => format!("{} days, {} hours", days(d), hours(d)),
|
||||
Some(d) => format!("{}d{}h{}m", days(d), hours(d), minutes(d)),
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue