From d738e7e5114a583c0b978bdf3c6b02e3ed52690a Mon Sep 17 00:00:00 2001 From: TMKnight <548588+tmknight@users.noreply.github.com> Date: Fri, 12 Jan 2024 10:20:43 -0500 Subject: [PATCH 1/2] Add TZ to logging --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index e8ab833..b38477d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,7 +7,7 @@ use std::time::Duration; // Logging async fn log_message(msg: &str) { - let date = Local::now().format("%Y-%m-%d %H:%M:%S").to_string(); + let date = Local::now().format("%Y-%m-%d %H:%M:%S%z").to_string(); let mut lock = stdout().lock(); writeln!(lock, "{} {}", date, msg).unwrap(); } From e8b3cafcdc10d1c7d773b96399838029f590eb27 Mon Sep 17 00:00:00 2001 From: tmknight Date: Sat, 13 Jan 2024 09:49:47 -0500 Subject: [PATCH 2/2] Refinement of log formatting --- src/main.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index b38477d..b1d59a9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -83,11 +83,11 @@ async fn main() -> Result<(), Box> { } } // Unwrap final connection paramaters - let msg0 = format!("[INFO] Monitoring Docker via {}", autoheal_connection_type); + let msg0 = format!("[INFO] Monitoring Docker via {}", autoheal_connection_type); log_message(&msg0).await; if autoheal_connection_type == "http" { let msg1 = format!( - "[INFO] Connecting to {}:{}", + "[INFO] Connecting to {}:{}", autoheal_tcp_host, autoheal_tcp_port ); log_message(&msg1).await; @@ -97,7 +97,7 @@ async fn main() -> Result<(), Box> { // Delay start of loop if specified if autoheal_start_delay > 0 { let msg0 = format!( - "[INFO] Delaying evaluation {}s on request", + "[INFO] Delaying evaluation {}s on request", autoheal_start_delay ); log_message(&msg0).await; @@ -130,7 +130,7 @@ async fn main() -> Result<(), Box> { let name_tmp = match &container.names { Some(names) => &names[0], None => { - let msg0 = format!("[ERROR] Could not reliably determine container name"); + let msg0 = format!("[ERROR] Could not reliably determine container name"); log_message(&msg0).await; "" } @@ -141,7 +141,7 @@ async fn main() -> Result<(), Box> { let id: String = match container.id { Some(id) => id.chars().take(12).collect(), None => { - let msg0 = format!("[ERROR] Could not reliably determine container id"); + let msg0 = format!("[ERROR] Could not reliably determine container id"); log_message(&msg0).await; "".to_string() } @@ -184,7 +184,7 @@ async fn main() -> Result<(), Box> { } } } else { - let msg0 = format!("[ERROR] Could not reliably identify the container"); + let msg0 = format!("[ERROR] Could not reliably identify the container"); log_message(&msg0).await; } });