From e036e14ad5072b9327b10caa2475593e707e26b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodolphe=20Br=C3=A9ard?= Date: Tue, 31 Dec 2024 15:35:10 +0100 Subject: [PATCH] Improve logs --- src/config.rs | 6 +++--- src/http.rs | 10 +++++----- src/main.rs | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/config.rs b/src/config.rs index ca060b5..d9c457d 100644 --- a/src/config.rs +++ b/src/config.rs @@ -150,9 +150,9 @@ pub fn load + std::fmt::Debug>(config_dir: P) -> Result>(), ) .build()?; - tracing::trace!(?settings, "loaded config"); + tracing::trace!("loaded config" = ?settings); let config: AcmedConfig = settings.try_deserialize().context("invalid setting")?; - tracing::debug!(?config, "computed config"); + tracing::debug!("computed config" = ?config); Ok(config) } @@ -170,7 +170,7 @@ fn get_files(config_dir: &Path) -> Result> { } } file_lst.sort(); - tracing::debug!(files = ?file_lst, "configuration files found"); + tracing::debug!("configuration files found" = ?file_lst); Ok(file_lst) } diff --git a/src/http.rs b/src/http.rs index e1685f5..0da3561 100644 --- a/src/http.rs +++ b/src/http.rs @@ -56,7 +56,7 @@ impl HttpRoutine { let (tx, rx) = mpsc::unbounded_channel(); let mut endpoints = HashMap::with_capacity(config.endpoint.len()); for (name, edp) in &config.endpoint { - tracing::debug!(name, "loading endpoint"); + tracing::debug!("endpoint name" = name, "loading endpoint"); let client = get_http_client(config.get_global_root_certs(), &edp.root_certificates); let endpoint = HttpEndpoint { client }; endpoints.insert(name.to_owned(), endpoint); @@ -74,14 +74,14 @@ impl HttpRoutine { pub(super) async fn run(mut self) { tracing::trace!("starting the http routine"); while let Some(raw_req) = self.rx.recv().await { - tracing::debug!(request = ?raw_req.request, "new http request"); + tracing::debug!("new http request" = ?raw_req.request); match self.endpoints.get(&raw_req.endpoint) { Some(edp) => { let ret = edp.client.execute(raw_req.request).await; let _ = raw_req.tx.send(ret); } None => { - tracing::error!(endpoint = raw_req.endpoint, "endpoint not found"); + tracing::error!("endpoint name" = raw_req.endpoint, "endpoint not found"); } } } @@ -95,9 +95,9 @@ macro_rules! add_root_cert { match get_cert_pem(cert_path) { Ok(cert) => { $builder = $builder.add_root_certificate(cert); - tracing::debug!(?cert_path, "root certificate loaded"); + tracing::debug!("path" = %cert_path.display(), "root certificate loaded"); } - Err(e) => tracing::error!(?cert_path, "{e:#?}",), + Err(e) => tracing::error!(path = ?cert_path, error = "{e:#?}", "unable to load root certificate"), } } }; diff --git a/src/main.rs b/src/main.rs index c39b9d9..b395435 100644 --- a/src/main.rs +++ b/src/main.rs @@ -24,7 +24,7 @@ fn main() { // Initialize the logging system log::init(args.log_level, !args.log.log_stderr); - tracing::trace!(?args, "computed args"); + tracing::trace!("computed args" = ?args); // Load the configuration let cfg = match config::load(args.config.as_path()) { @@ -70,7 +70,7 @@ async fn debug_remove_me(http_client: crate::http::HttpClient) { Request::new(Method::GET, Url::parse("https://example.invalid").unwrap()), ) .await; - tracing::debug!(response = ?rsp, "response received"); + tracing::debug!("response received" = ?rsp); let rsp = http_client .send( "my-ca", @@ -80,7 +80,7 @@ async fn debug_remove_me(http_client: crate::http::HttpClient) { ), ) .await; - tracing::debug!(response = ?rsp, "response received"); + tracing::debug!("response received" = ?rsp); } #[tracing::instrument(level = "trace", err(Debug))]