Remove test_logger feature (#9125)

- #9107


  Remove all instances of `test_logger` in the code


Co-Authored-By: Tan Chee Keong <tanck@sigmaprime.io>
This commit is contained in:
chonghe
2026-04-30 12:57:47 +08:00
committed by GitHub
parent 04b2589807
commit 8d77b1c08d
5 changed files with 33 additions and 37 deletions

View File

@@ -4,12 +4,11 @@ version = "0.2.0"
authors = ["blacktemplar <blacktemplar@a1.net>"]
edition = { workspace = true }
[features]
# Print log output to stderr when running tests instead of dropping it.
test_logger = []
[dependencies]
chrono = { version = "0.4", default-features = false, features = ["clock", "std"] }
chrono = { version = "0.4", default-features = false, features = [
"clock",
"std",
] }
logroller = { workspace = true }
metrics = { workspace = true }
serde = { workspace = true }

View File

@@ -42,16 +42,15 @@ impl TimeLatch {
/// Return a tracing subscriber suitable for test usage.
///
/// By default no logs will be printed, but they can be enabled via
/// the `test_logger` feature. This feature can be enabled for any
/// dependent crate by passing `--features logging/test_logger`, e.g.
/// By default no logs will be printed, logs will be printed by using --nocapture. Example:
/// ```bash
/// cargo test -p beacon_chain --features logging/test_logger
/// cargo test --release -p beacon_chain -- --nocapture
/// ```
pub fn create_test_tracing_subscriber() {
if cfg!(feature = "test_logger") {
let _ = tracing_subscriber::fmt()
.with_env_filter(EnvFilter::try_new("debug").unwrap())
.try_init();
}
let _ = tracing_subscriber::fmt()
.with_test_writer()
.with_env_filter(
EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("debug")),
)
.try_init();
}