fix(cli): avoid debug logging by default in CLI (#7569)
Signed-off-by: WhiskerSage <15216859336@163.com>
This commit is contained in:
@@ -12,6 +12,15 @@ use goose::tracing::langfuse_layer;
|
||||
// Used to ensure we only set up tracing once
|
||||
static INIT: Once = Once::new();
|
||||
|
||||
fn default_env_filter() -> EnvFilter {
|
||||
EnvFilter::new("")
|
||||
// Keep goose and MCP logs visible without verbose debug payloads.
|
||||
.add_directive("mcp_client=info".parse().unwrap())
|
||||
.add_directive("goose=info".parse().unwrap())
|
||||
.add_directive("goose_cli=info".parse().unwrap())
|
||||
.add_directive(LevelFilter::WARN.into())
|
||||
}
|
||||
|
||||
/// Sets up the logging infrastructure for the application.
|
||||
/// This includes:
|
||||
/// - File-based logging with JSON formatting (DEBUG level)
|
||||
@@ -49,18 +58,8 @@ fn setup_logging_internal(name: Option<&str>, force: bool) -> Result<()> {
|
||||
.json();
|
||||
|
||||
// Base filter
|
||||
let env_filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| {
|
||||
// Set default levels for different modules
|
||||
EnvFilter::new("")
|
||||
// Set mcp-client to DEBUG
|
||||
.add_directive("mcp_client=debug".parse().unwrap())
|
||||
// Set goose module to DEBUG
|
||||
.add_directive("goose=debug".parse().unwrap())
|
||||
// Set goose-cli to INFO
|
||||
.add_directive("goose_cli=info".parse().unwrap())
|
||||
// Set everything else to WARN
|
||||
.add_directive(LevelFilter::WARN.into())
|
||||
});
|
||||
let env_filter =
|
||||
EnvFilter::try_from_default_env().unwrap_or_else(|_| default_env_filter());
|
||||
|
||||
// Start building the subscriber
|
||||
let mut layers = vec![
|
||||
@@ -188,4 +187,14 @@ mod tests {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_default_filter_avoids_debug_by_default() {
|
||||
let filter = super::default_env_filter().to_string();
|
||||
assert!(!filter.contains("mcp_client=debug"));
|
||||
assert!(!filter.contains("goose=debug"));
|
||||
assert!(filter.contains("mcp_client=info"));
|
||||
assert!(filter.contains("goose=info"));
|
||||
assert!(filter.contains("goose_cli=info"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user