From 8b1e397211d9594fbcb9f7de3c363a90e6bc99ef Mon Sep 17 00:00:00 2001 From: pakrym-oai Date: Tue, 2 Dec 2025 07:57:55 -0800 Subject: [PATCH] Add request logging back (#7471) Having full requests helps debugging --- codex-rs/Cargo.lock | 1 + codex-rs/codex-client/Cargo.toml | 9 +++++---- codex-rs/codex-client/src/transport.rs | 12 ++++++++++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/codex-rs/Cargo.lock b/codex-rs/Cargo.lock index adbb2fa77..c1f2bc284 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 2defe12fd..d1ff23ef3 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 f64e72fb6..5edc9a7b7 100644 --- a/codex-rs/codex-client/src/transport.rs +++ b/codex-rs/codex-client/src/transport.rs @@ -8,6 +8,9 @@ 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>; @@ -83,6 +86,15 @@ impl HttpTransport for ReqwestTransport { } async fn stream(&self, req: Request) -> Result { + 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)?; let status = resp.status();