fix(main): add more logging and default to info #31

Merged
jalil merged 1 commit from more-logs into main 2024-12-26 17:26:53 +01:00
4 changed files with 16 additions and 6 deletions
Showing only changes of commit e9d5b87ecc - Show all commits

View file

@ -2,6 +2,12 @@
All notable changes to this project will be documented in this file. 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 ## [0.3.3] - 2024-12-22
### 🚀 Features ### 🚀 Features

2
Cargo.lock generated
View file

@ -1139,7 +1139,7 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]] [[package]]
name = "webnsupdate" name = "webnsupdate"
version = "0.3.3" version = "0.3.4"
dependencies = [ dependencies = [
"axum", "axum",
"axum-client-ip", "axum-client-ip",

View file

@ -3,7 +3,7 @@ cargo-features = ["codegen-backend"]
[package] [package]
description = "An HTTP server using HTTP basic auth to make secure calls to nsupdate" description = "An HTTP server using HTTP basic auth to make secure calls to nsupdate"
name = "webnsupdate" name = "webnsupdate"
version = "0.3.3" version = "0.3.4"
edition = "2021" edition = "2021"
license-file = "LICENSE" license-file = "LICENSE"
readme = "README.md" readme = "README.md"

View file

@ -26,7 +26,7 @@ const DEFAULT_SALT: &str = "UpdateMyDNS";
#[derive(Debug, Parser)] #[derive(Debug, Parser)]
struct Opts { struct Opts {
#[command(flatten)] #[command(flatten)]
verbosity: Verbosity<clap_verbosity_flag::WarnLevel>, verbosity: Verbosity<clap_verbosity_flag::InfoLevel>,
/// Ip address of the server /// Ip address of the server
#[arg(long, default_value = "127.0.0.1")] #[arg(long, default_value = "127.0.0.1")]
@ -188,6 +188,7 @@ fn load_ip(path: &Path) -> Result<Option<IpAddr>> {
)) ))
} }
#[tracing::instrument(err)]
fn main() -> Result<()> { fn main() -> Result<()> {
// set panic hook to pretty print with miette's formatter // set panic hook to pretty print with miette's formatter
miette::set_panic_hook(); miette::set_panic_hook();
@ -204,9 +205,10 @@ fn main() -> Result<()> {
.from_env_lossy(), .from_env_lossy(),
) )
.finish(); .finish();
tracing::subscriber::set_global_default(subscriber) tracing::subscriber::set_global_default(subscriber)
.into_diagnostic() .into_diagnostic()
.wrap_err("setting global tracing subscriber")?; .wrap_err("failed to set global tracing subscriber")?;
debug!("{args:?}"); debug!("{args:?}");
@ -249,7 +251,8 @@ fn main() -> Result<()> {
Ok(pass) Ok(pass)
}) })
.transpose()?; .transpose()
.wrap_err("failed to load password hash")?;
ensure!( ensure!(
password_hash.is_some() || insecure, password_hash.is_some() || insecure,
@ -283,7 +286,7 @@ fn main() -> Result<()> {
} }
Ok(None) => info!("No previous IP address set"), 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 // Create services
@ -310,6 +313,7 @@ fn main() -> Result<()> {
.await .await
.into_diagnostic() .into_diagnostic()
}) })
.wrap_err("failed to run main loop")
} }
#[tracing::instrument(skip(state), level = "trace", ret(level = "info"))] #[tracing::instrument(skip(state), level = "trace", ret(level = "info"))]