From 718d2170037190f3b91dd3896a514365f1940cca Mon Sep 17 00:00:00 2001 From: erenoku Date: Sun, 23 Oct 2022 12:35:39 +0300 Subject: [PATCH] Print timestamp with each status update --- Cargo.lock | 1 + crates/fj-interop/Cargo.toml | 1 + crates/fj-interop/src/status_report.rs | 6 +++++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index e9be735fd..cd02626ed 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1006,6 +1006,7 @@ dependencies = [ name = "fj-interop" version = "0.20.0" dependencies = [ + "chrono", "fj-math", ] diff --git a/crates/fj-interop/Cargo.toml b/crates/fj-interop/Cargo.toml index e40226a36..cf6bf44e5 100644 --- a/crates/fj-interop/Cargo.toml +++ b/crates/fj-interop/Cargo.toml @@ -11,4 +11,5 @@ keywords.workspace = true categories.workspace = true [dependencies] +chrono = "0.4.22" fj-math.workspace = true diff --git a/crates/fj-interop/src/status_report.rs b/crates/fj-interop/src/status_report.rs index f5c645da2..d0e3ec58d 100644 --- a/crates/fj-interop/src/status_report.rs +++ b/crates/fj-interop/src/status_report.rs @@ -2,6 +2,8 @@ use std::collections::VecDeque; +use chrono::Local; + /// Struct to store and update status messages #[derive(Default)] pub struct StatusReport { @@ -16,7 +18,9 @@ impl StatusReport { /// Update the status pub fn update_status(&mut self, status: &str) { - let status = format!("\n{}", status.to_owned()); + let date = Local::now(); + let status = + format!("\n{} {}", date.format("[%H:%M:%S]"), status.to_owned()); self.status.push_back(status); if self.status.len() > 5 { for _ in 0..(self.status.len() - 5) {