From e9d5b87ecc275fcbb37468772913bfc43943920c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jalil=20David=20Salam=C3=A9=20Messina?= Date: Thu, 26 Dec 2024 17:11:26 +0100 Subject: [PATCH] fix(main): add more logging and default to info `leo` fails to run with v0.3.3 so we are adding a bit more logging to debug the case. As part of this, change default log level to `info`. --- CHANGELOG.md | 6 ++++++ Cargo.lock | 2 +- Cargo.toml | 2 +- src/main.rs | 12 ++++++++---- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 579ac5b..64cc1c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ All notable changes to this project will be documented in this file. +## [0.3.4] - 2024-12-26 + +### 🐛 Bug Fixes + +- *(main)* Add more logging and default to info + ## [0.3.3] - 2024-12-22 ### 🚀 Features diff --git a/Cargo.lock b/Cargo.lock index 65afa01..c399cae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1139,7 +1139,7 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "webnsupdate" -version = "0.3.3" +version = "0.3.4" dependencies = [ "axum", "axum-client-ip", diff --git a/Cargo.toml b/Cargo.toml index bc20a94..34a2ca2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ cargo-features = ["codegen-backend"] [package] description = "An HTTP server using HTTP basic auth to make secure calls to nsupdate" name = "webnsupdate" -version = "0.3.3" +version = "0.3.4" edition = "2021" license-file = "LICENSE" readme = "README.md" diff --git a/src/main.rs b/src/main.rs index b612c38..d2b9136 100644 --- a/src/main.rs +++ b/src/main.rs @@ -26,7 +26,7 @@ const DEFAULT_SALT: &str = "UpdateMyDNS"; #[derive(Debug, Parser)] struct Opts { #[command(flatten)] - verbosity: Verbosity, + verbosity: Verbosity, /// Ip address of the server #[arg(long, default_value = "127.0.0.1")] @@ -188,6 +188,7 @@ fn load_ip(path: &Path) -> Result> { )) } +#[tracing::instrument(err)] fn main() -> Result<()> { // set panic hook to pretty print with miette's formatter miette::set_panic_hook(); @@ -204,9 +205,10 @@ fn main() -> Result<()> { .from_env_lossy(), ) .finish(); + tracing::subscriber::set_global_default(subscriber) .into_diagnostic() - .wrap_err("setting global tracing subscriber")?; + .wrap_err("failed to set global tracing subscriber")?; debug!("{args:?}"); @@ -249,7 +251,8 @@ fn main() -> Result<()> { Ok(pass) }) - .transpose()?; + .transpose() + .wrap_err("failed to load password hash")?; ensure!( password_hash.is_some() || insecure, @@ -283,7 +286,7 @@ fn main() -> Result<()> { } Ok(None) => info!("No previous IP address set"), - Err(err) => error!("Failed to load last ip address: {err}"), + Err(err) => error!("Ignoring previous IP due to: {err}"), }; // Create services @@ -310,6 +313,7 @@ fn main() -> Result<()> { .await .into_diagnostic() }) + .wrap_err("failed to run main loop") } #[tracing::instrument(skip(state), level = "trace", ret(level = "info"))] -- 2.47.0