From 392fdd7db6e750cdefa158a62324fab54ca6dfe8 Mon Sep 17 00:00:00 2001 From: Michael Bolin Date: Wed, 28 May 2025 17:10:06 -0700 Subject: [PATCH] fix: honor RUST_LOG in mcp-client CLI and default to DEBUG (#1149) We had `debug!()` logging statements already, but they weren't being printed because `tracing_subscriber` was not set up. --- codex-rs/mcp-client/src/main.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/codex-rs/mcp-client/src/main.rs b/codex-rs/mcp-client/src/main.rs index af4b0509..518383d1 100644 --- a/codex-rs/mcp-client/src/main.rs +++ b/codex-rs/mcp-client/src/main.rs @@ -20,9 +20,22 @@ use mcp_types::Implementation; use mcp_types::InitializeRequestParams; use mcp_types::ListToolsRequestParams; use mcp_types::MCP_SCHEMA_VERSION; +use tracing_subscriber::EnvFilter; #[tokio::main] async fn main() -> Result<()> { + let default_level = "debug"; + let _ = tracing_subscriber::fmt() + // Fallback to the `default_level` log filter if the environment + // variable is not set _or_ contains an invalid value + .with_env_filter( + EnvFilter::try_from_default_env() + .or_else(|_| EnvFilter::try_new(default_level)) + .unwrap_or_else(|_| EnvFilter::new(default_level)), + ) + .with_writer(std::io::stderr) + .try_init(); + // Collect command-line arguments excluding the program name itself. let mut args: Vec = std::env::args().skip(1).collect();