From f107b74d28cfadbfdf163c30f394df9c2969c7a7 Mon Sep 17 00:00:00 2001 From: Surya Ganesh Date: Sun, 29 Mar 2026 11:22:34 -0400 Subject: [PATCH 1/3] disable debug logging for h2 library. this can still be enabled by `RUST_LOG=debug,h2=debug` --- crates/lib/src/util/logging.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/lib/src/util/logging.rs b/crates/lib/src/util/logging.rs index 905177d07..d7b00c1da 100644 --- a/crates/lib/src/util/logging.rs +++ b/crates/lib/src/util/logging.rs @@ -17,6 +17,7 @@ macro_rules! current_function { pub fn init_logging() { match env_logger::Builder::from_env(Env::default()) + .filter_module("h2", log::LevelFilter::Warn) .format(|buf, record| { use crate::request_context::get_request_id; From 8cfd3105e2d92b41e86003001ba37d55baa9a9b3 Mon Sep 17 00:00:00 2001 From: Surya Ganesh Date: Mon, 30 Mar 2026 12:00:27 -0400 Subject: [PATCH 2/3] clear up logs from other library as well as, show request id in client side logs --- crates/lib/src/api/client.rs | 21 ++++++++++++++++++--- crates/lib/src/api/client/entries.rs | 7 ++++--- crates/lib/src/config/auth_config.rs | 2 +- crates/lib/src/util/logging.rs | 2 ++ 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/crates/lib/src/api/client.rs b/crates/lib/src/api/client.rs index 447a9e027..f74ae8ce7 100644 --- a/crates/lib/src/api/client.rs +++ b/crates/lib/src/api/client.rs @@ -128,7 +128,7 @@ fn builder_for_host(host: String, should_add_user_agent: bool) -> Result header, @@ -181,6 +181,15 @@ pub async fn parse_json_body(url: &str, res: reqwest::Response) -> Result &str { + response + .headers() + .get("x-oxen-request-id") + .and_then(|v| v.to_str().ok()) + .unwrap_or("-") +} + /// Used to override error message when parsing json body async fn parse_json_body_with_err_msg( url: &str, @@ -189,10 +198,10 @@ async fn parse_json_body_with_err_msg( response_msg_override: Option<&str>, ) -> Result { let status = res.status(); + let request_id = get_request_id(&res); + log::debug!("url: {url}\nstatus: {status} request_id: {request_id}"); let body = res.text().await?; - log::debug!("url: {url}\nstatus: {status}"); - let response: Result = serde_json::from_str(&body); log::debug!("response: {response:?}"); match response { @@ -262,6 +271,12 @@ pub async fn handle_non_json_response( url: &str, res: reqwest::Response, ) -> Result { + let request_id = get_request_id(&res); + log::debug!( + "url: {url}\nstatus: {} request_id: {request_id}", + res.status() + ); + if res.status().is_success() || res.status().is_redirection() { // If the response is successful, return it as-is. We don't want to do any parsing here. return Ok(res); diff --git a/crates/lib/src/api/client/entries.rs b/crates/lib/src/api/client/entries.rs index 4e6769bdc..d39023337 100644 --- a/crates/lib/src/api/client/entries.rs +++ b/crates/lib/src/api/client/entries.rs @@ -501,14 +501,15 @@ async fn pull_entry_chunk( let client = client::new_for_url(&url)?; let response = client.get(&url).send().await?; - + let request_id = client::get_request_id(&response); let status = response.status(); log::debug!( - "pull_entry_chunk response status={} for path={:?} chunk_start={} chunk_size={}", + "pull_entry_chunk status={} path={:?} chunk_start={} chunk_size={} request_id: {}", status, remote_path, chunk_start, - chunk_size + chunk_size, + request_id ); match status { diff --git a/crates/lib/src/config/auth_config.rs b/crates/lib/src/config/auth_config.rs index 5a29c33f3..2633dc148 100644 --- a/crates/lib/src/config/auth_config.rs +++ b/crates/lib/src/config/auth_config.rs @@ -74,7 +74,7 @@ impl AuthConfig { Err(_) => config_dir.join(Path::new(AUTH_CONFIG_FILENAME)), }; - log::debug!("looking for config file in...{config_file:?}"); + log::trace!("looking for config file in...{config_file:?}"); if config_file.exists() { Ok(AuthConfig::new(&config_file)) } else { diff --git a/crates/lib/src/util/logging.rs b/crates/lib/src/util/logging.rs index d7b00c1da..81f769b66 100644 --- a/crates/lib/src/util/logging.rs +++ b/crates/lib/src/util/logging.rs @@ -18,6 +18,8 @@ macro_rules! current_function { pub fn init_logging() { match env_logger::Builder::from_env(Env::default()) .filter_module("h2", log::LevelFilter::Warn) + .filter_module("hyper_util", log::LevelFilter::Warn) + .filter_module("reqwest", log::LevelFilter::Warn) .format(|buf, record| { use crate::request_context::get_request_id; From f1f63a18d54ce1e23ba13722c492e771901cf3cd Mon Sep 17 00:00:00 2001 From: Surya Ganesh Date: Mon, 30 Mar 2026 12:19:11 -0400 Subject: [PATCH 3/3] fix env variable precendance --- crates/lib/src/util/logging.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/crates/lib/src/util/logging.rs b/crates/lib/src/util/logging.rs index 81f769b66..630d36b76 100644 --- a/crates/lib/src/util/logging.rs +++ b/crates/lib/src/util/logging.rs @@ -16,10 +16,14 @@ macro_rules! current_function { } pub fn init_logging() { - match env_logger::Builder::from_env(Env::default()) - .filter_module("h2", log::LevelFilter::Warn) - .filter_module("hyper_util", log::LevelFilter::Warn) - .filter_module("reqwest", log::LevelFilter::Warn) + let mut builder = env_logger::Builder::new(); + // ignore noisy http logs + builder.filter_module("h2", log::LevelFilter::Warn); + builder.filter_module("hyper_util", log::LevelFilter::Warn); + builder.filter_module("reqwest", log::LevelFilter::Warn); + + builder.parse_env(Env::default()); + match builder .format(|buf, record| { use crate::request_context::get_request_id;