Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 25 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,20 +180,38 @@ Key points:

#[tokio::main]
async fn main() -> Result<()> {
let cli = Cli::parse();

// Initialize logging based on transport mode
// For stdio transport, default to "off" to avoid interfering with MCP protocol
// For HTTP transport, keep the existing default logging level
let default_log_level = match &cli.command {
Commands::Serve { stdio, http, .. } => {
match (*stdio, *http) {
(false, false) | (true, false) => {
// Using stdio transport (default or explicit) - disable logging by default
"off"
}
(false, true) => {
// Using HTTP transport - keep existing logging behavior
"info,cranelift_codegen=warn,cranelift_entity=warn,cranelift_bforest=warn,cranelift_frontend=warn"
}
(true, true) => {
// Invalid combination - will error later, but use "off" for now
"off"
}
}
}
};

tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| {
"info,cranelift_codegen=warn,cranelift_entity=warn,cranelift_bforest=warn,cranelift_frontend=warn"
.to_string()
.into()
}),
.unwrap_or_else(|_| default_log_level.to_string().into()),
)
.with(tracing_subscriber::fmt::layer())
.init();

let cli = Cli::parse();

match &cli.command {
Commands::Serve {
plugin_dir,
Expand Down