From 9f203f375fbe338f40cb7418bac4773a58f6d5e8 Mon Sep 17 00:00:00 2001 From: ddidderr Date: Mon, 12 Oct 2026 21:27:00 +0200 Subject: [PATCH] fix(logging): default to errors only in all build modes Honor the request for quiet default logging by showing only errors in both debug and release builds. Previously, development builds logged at debug level and release builds at info level. Set the default filter to error in the core logger, WebAssembly logger, and GTK demo. Keep the existing RUST_LOG overrides in the native logger and demo so users can enable more detail when troubleshooting. WebAssembly continues to use a fixed filter without an environment override. Update logger comments to describe the new default. Test Plan: - Passed: cargo test -p ghostty-core global::tests --lib (3 tests). - Passed: git diff --check. - Manual: launch without RUST_LOG and confirm only errors are logged; use RUST_LOG=debug to confirm native verbose logging remains available. - WebAssembly and the GTK demo were not built or run. Requested-by: User request for errors-only default logging --- crates/ghostty-apprt-gtk/examples/demo.rs | 2 +- crates/ghostty-core/src/global.rs | 7 +++---- crates/ghostty-os/src/wasm/log.rs | 10 ++-------- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/crates/ghostty-apprt-gtk/examples/demo.rs b/crates/ghostty-apprt-gtk/examples/demo.rs index 4a067f8..4951d00 100644 --- a/crates/ghostty-apprt-gtk/examples/demo.rs +++ b/crates/ghostty-apprt-gtk/examples/demo.rs @@ -340,7 +340,7 @@ impl CoreApp for DemoApp { } fn main() { - env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init(); + env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("error")).init(); let core = Rc::new(DemoApp::default()); let app = App::new(core); diff --git a/crates/ghostty-core/src/global.rs b/crates/ghostty-core/src/global.rs index 011fa96..083d5d2 100644 --- a/crates/ghostty-core/src/global.rs +++ b/crates/ghostty-core/src/global.rs @@ -359,16 +359,15 @@ impl log::Log for Logger { } fn init_logger(logging: Logging) { - // Our log level is always at least info in every build mode; debug - // builds (or RUST_LOG=debug) also show debug messages. + // Only show errors by default in every build mode. RUST_LOG can opt + // into more verbose logging when needed. let max = match std::env::var("RUST_LOG").ok().as_deref() { Some("trace") => log::LevelFilter::Trace, Some("debug") => log::LevelFilter::Debug, Some("warn") => log::LevelFilter::Warn, Some("error") => log::LevelFilter::Error, Some("info") => log::LevelFilter::Info, - _ if cfg!(debug_assertions) => log::LevelFilter::Debug, - _ => log::LevelFilter::Info, + _ => log::LevelFilter::Error, }; let logger = Box::new(Logger { stderr: logging.stderr, diff --git a/crates/ghostty-os/src/wasm/log.rs b/crates/ghostty-os/src/wasm/log.rs index a05881d..4103041 100644 --- a/crates/ghostty-os/src/wasm/log.rs +++ b/crates/ghostty-os/src/wasm/log.rs @@ -62,15 +62,9 @@ impl Log for Logger { static LOGGER: Logger = Logger; -/// Installs the logger. Zig's level: debug in Debug, warn in ReleaseSmall, -/// info otherwise; here debug with `debug_assertions`, info otherwise. +/// Installs the logger with errors only in every build mode. pub fn init() { - let level = if cfg!(debug_assertions) { - LevelFilter::Debug - } else { - LevelFilter::Info - }; if ::log::set_logger(&LOGGER).is_ok() { - ::log::set_max_level(level); + ::log::set_max_level(LevelFilter::Error); } }