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..5edc9a7b77 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();