Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refinements to logging #16

Merged
merged 3 commits into from
Jan 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -83,11 +83,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
}
}
// 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;
Expand All @@ -97,7 +97,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// 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;
Expand Down Expand Up @@ -130,7 +130,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
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;
""
}
Expand All @@ -141,7 +141,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
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()
}
Expand Down Expand Up @@ -184,7 +184,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
}
}
} 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;
}
});
Expand Down