From 33808beef16f9861fa9bf252bcb59affe6d3d981 Mon Sep 17 00:00:00 2001 From: Ikeh Celestine Chukwudi Date: Wed, 14 Oct 2026 21:34:39 +0100 Subject: [PATCH 1/2] fix(log): show warnings by default env_logger only shows errors when RUST_LOG is unset, so every warn!, including the mainnet notice, was hidden from users. Default the filter to warn while keeping RUST_LOG as an override, and add tests for both cases. Fixes #352 --- src/main.rs | 2 +- tests/integration/init.rs | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 06e3ea24..d13bf8a9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -33,7 +33,7 @@ use clap::{CommandFactory, Parser}; #[tokio::main] async fn main() { - env_logger::init(); + env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("warn")).init(); let cli_opts: CliOpts = CliOpts::parse(); let network = &cli_opts.network; diff --git a/tests/integration/init.rs b/tests/integration/init.rs index 120341ab..12086ff6 100644 --- a/tests/integration/init.rs +++ b/tests/integration/init.rs @@ -120,6 +120,30 @@ mod test_wallets { .stderr(predicate::str::contains("No wallets configured yet.")); } + #[test] + fn test_mainnet_warning_shown_by_default() { + let temp_dir = TempDir::new().unwrap(); + let cli = BdkCli::new("bitcoin", Some(temp_dir.path().to_path_buf())); + + cli.cmd("wallets", &[]) + .env_remove("RUST_LOG") + .assert() + .stderr(predicate::str::contains( + "not currently recommended for use on Bitcoin mainnet", + )); + } + + #[test] + fn test_mainnet_warning_hidden_with_rust_log_error() { + let temp_dir = TempDir::new().unwrap(); + let cli = BdkCli::new("bitcoin", Some(temp_dir.path().to_path_buf())); + + cli.cmd("wallets", &[]) + .env("RUST_LOG", "error") + .assert() + .stderr(predicate::str::contains("not currently recommended").not()); + } + #[cfg(feature = "rpc")] #[test] fn test_list_wallets_with_entries() { From 3f6b0230ff433c13322dcb54b82f0df51f843df0 Mon Sep 17 00:00:00 2001 From: Ikeh Celestine Chukwudi Date: Wed, 14 Oct 2026 22:14:27 +0100 Subject: [PATCH 2/2] docs(changelog): note warnings shown by default --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b68802b3..916b581a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ page. See [DEVELOPMENT_CYCLE.md](DEVELOPMENT_CYCLE.md) for more details. - Routed compact filter (cbf) traffic through the configured SOCKS5 proxy - Rejected `--proxy` on the `rpc` backend, and unsupported proxy options (`--proxy_auth`, `--timeout`) on the `rpc` and `cbf` backends, instead of silently ignoring them - Fixed `compile` rejecting policies that are valid for the requested script type +- Fixed `warn!` messages, including the mainnet notice, being hidden unless `RUST_LOG` was set; warnings are now shown by default ## [4.0.0]