From 260e2a280a0c7b6d14746d45e6dad3032e5ea094 Mon Sep 17 00:00:00 2001 From: pakrym-oai Date: Mon, 1 Dec 2025 15:34:12 -0800 Subject: [PATCH 1/2] Add request logging back --- codex-rs/Cargo.lock | 1 + codex-rs/codex-client/Cargo.toml | 9 +++++---- codex-rs/codex-client/src/transport.rs | 8 ++++++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/codex-rs/Cargo.lock b/codex-rs/Cargo.lock index 2320afeecb..a8aa022f22 100644 --- a/codex-rs/Cargo.lock +++ b/codex-rs/Cargo.lock @@ -1068,6 +1068,7 @@ dependencies = [ "serde_json", "thiserror 2.0.17", "tokio", + "tracing", ] [[package]] diff --git a/codex-rs/codex-client/Cargo.toml b/codex-rs/codex-client/Cargo.toml index 2defe12fda..d1ff23ef36 100644 --- a/codex-rs/codex-client/Cargo.toml +++ b/codex-rs/codex-client/Cargo.toml @@ -1,21 +1,22 @@ [package] -name = "codex-client" -version.workspace = true edition.workspace = true license.workspace = true +name = "codex-client" +version.workspace = true [dependencies] async-trait = { workspace = true } bytes = { workspace = true } +eventsource-stream = { workspace = true } futures = { workspace = true } http = { workspace = true } +rand = { workspace = true } reqwest = { workspace = true, features = ["json", "stream"] } serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true } thiserror = { workspace = true } tokio = { workspace = true, features = ["macros", "rt", "time", "sync"] } -rand = { workspace = true } -eventsource-stream = { workspace = true } +tracing = { workspace = true } [lints] workspace = true diff --git a/codex-rs/codex-client/src/transport.rs b/codex-rs/codex-client/src/transport.rs index f64e72fb68..c91bd15f99 100644 --- a/codex-rs/codex-client/src/transport.rs +++ b/codex-rs/codex-client/src/transport.rs @@ -8,6 +8,7 @@ use futures::stream::BoxStream; use http::HeaderMap; use http::Method; use http::StatusCode; +use tracing::trace; pub type ByteStream = BoxStream<'static, Result>; @@ -83,6 +84,13 @@ impl HttpTransport for ReqwestTransport { } async fn stream(&self, req: Request) -> Result { + trace!( + "{} to {}: {}", + req.method, + req.url, + req.body.as_ref().unwrap_or_default() + ); + let builder = self.build(req)?; let resp = builder.send().await.map_err(Self::map_error)?; let status = resp.status(); From 300170d1395ac1a2cd94270dd9d5403d43eabaab Mon Sep 17 00:00:00 2001 From: pakrym-oai Date: Mon, 1 Dec 2025 15:37:41 -0800 Subject: [PATCH 2/2] transport: guard trace logging with enabled! macro --- codex-rs/codex-client/src/transport.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/codex-rs/codex-client/src/transport.rs b/codex-rs/codex-client/src/transport.rs index c91bd15f99..5edc9a7b77 100644 --- a/codex-rs/codex-client/src/transport.rs +++ b/codex-rs/codex-client/src/transport.rs @@ -8,6 +8,8 @@ use futures::stream::BoxStream; use http::HeaderMap; use http::Method; use http::StatusCode; +use tracing::Level; +use tracing::enabled; use tracing::trace; pub type ByteStream = BoxStream<'static, Result>; @@ -84,12 +86,14 @@ impl HttpTransport for ReqwestTransport { } async fn stream(&self, req: Request) -> Result { - trace!( - "{} to {}: {}", - req.method, - req.url, - req.body.as_ref().unwrap_or_default() - ); + if enabled!(Level::TRACE) { + trace!( + "{} to {}: {}", + req.method, + req.url, + req.body.as_ref().unwrap_or_default() + ); + } let builder = self.build(req)?; let resp = builder.send().await.map_err(Self::map_error)?;