diff --git a/Cargo.lock b/Cargo.lock index 7466975fa428..b89cdf7828c8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1477,11 +1477,11 @@ name = "binary-merkle-tree" version = "13.0.0" dependencies = [ "array-bytes", - "env_logger 0.11.3", "hash-db", "log", "sp-core", "sp-runtime", + "sp-tracing 16.0.0", ] [[package]] @@ -5267,7 +5267,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea" dependencies = [ "log", - "regex", ] [[package]] @@ -5302,7 +5301,6 @@ dependencies = [ "anstream", "anstyle", "env_filter", - "humantime", "log", ] @@ -5967,12 +5965,12 @@ version = "0.1.0" dependencies = [ "clap 4.5.11", "cumulus-primitives-proof-size-hostfunction", - "env_logger 0.11.3", "frame-benchmarking-cli", "log", "sc-cli", "sp-runtime", "sp-statement-store", + "sp-tracing 16.0.0", ] [[package]] @@ -10307,7 +10305,6 @@ dependencies = [ "array-bytes", "assert_matches", "bitflags 1.3.2", - "env_logger 0.11.3", "environmental", "frame-benchmarking", "frame-support", @@ -10985,7 +10982,6 @@ name = "pallet-mmr" version = "27.0.0" dependencies = [ "array-bytes", - "env_logger 0.11.3", "frame-benchmarking", "frame-support", "frame-system", @@ -10997,6 +10993,7 @@ dependencies = [ "sp-io", "sp-mmr-primitives", "sp-runtime", + "sp-tracing 16.0.0", ] [[package]] @@ -12861,7 +12858,6 @@ version = "7.0.0" dependencies = [ "assert_matches", "bitvec", - "env_logger 0.11.3", "futures", "futures-timer", "itertools 0.11.0", @@ -12881,6 +12877,7 @@ dependencies = [ "schnorrkel 0.11.4", "sp-authority-discovery", "sp-core", + "sp-tracing 16.0.0", "tracing-gum", ] @@ -12891,10 +12888,8 @@ dependencies = [ "always-assert", "assert_matches", "bitvec", - "env_logger 0.11.3", "futures", "futures-timer", - "log", "maplit", "polkadot-node-network-protocol", "polkadot-node-subsystem", @@ -12908,6 +12903,7 @@ dependencies = [ "sp-core", "sp-keyring", "sp-keystore", + "sp-tracing 16.0.0", "tracing-gum", ] @@ -13020,11 +13016,9 @@ version = "7.0.0" dependencies = [ "assert_matches", "bitvec", - "env_logger 0.11.3", "fatality", "futures", "futures-timer", - "log", "parity-scale-codec", "polkadot-node-network-protocol", "polkadot-node-primitives", @@ -13040,6 +13034,7 @@ dependencies = [ "sp-keyring", "sp-keystore", "sp-runtime", + "sp-tracing 16.0.0", "thiserror", "tokio-util", "tracing-gum", @@ -13193,7 +13188,6 @@ dependencies = [ "async-trait", "bitvec", "derive_more", - "env_logger 0.11.3", "futures", "futures-timer", "itertools 0.11.0", @@ -13226,6 +13220,7 @@ dependencies = [ "sp-keyring", "sp-keystore", "sp-runtime", + "sp-tracing 16.0.0", "thiserror", "tracing-gum", ] @@ -13236,7 +13231,6 @@ version = "7.0.0" dependencies = [ "assert_matches", "bitvec", - "env_logger 0.11.3", "futures", "futures-timer", "kvdb", @@ -13256,6 +13250,7 @@ dependencies = [ "sp-consensus", "sp-core", "sp-keyring", + "sp-tracing 16.0.0", "thiserror", "tracing-gum", ] @@ -13777,7 +13772,6 @@ dependencies = [ "assert_matches", "async-trait", "derive_more", - "env_logger 0.11.3", "fatality", "futures", "futures-channel", @@ -14665,7 +14659,6 @@ dependencies = [ "assert_matches", "async-trait", "bitvec", - "env_logger 0.11.3", "frame-benchmarking", "frame-benchmarking-cli", "frame-metadata-hash-extension", @@ -14773,6 +14766,7 @@ dependencies = [ "sp-state-machine", "sp-storage 19.0.0", "sp-timestamp", + "sp-tracing 16.0.0", "sp-transaction-pool", "sp-version", "sp-weights", @@ -14843,7 +14837,6 @@ dependencies = [ "clap-num", "color-eyre", "colored", - "env_logger 0.11.3", "futures", "futures-timer", "hex", @@ -14896,6 +14889,7 @@ dependencies = [ "sp-keystore", "sp-runtime", "sp-timestamp", + "sp-tracing 16.0.0", "strum 0.26.2", "substrate-prometheus-endpoint", "tokio", @@ -16214,7 +16208,6 @@ dependencies = [ "backoff", "bp-runtime", "console", - "env_logger 0.11.3", "futures", "isahc", "jsonpath_lib", @@ -16223,6 +16216,7 @@ dependencies = [ "parking_lot 0.12.3", "serde_json", "sp-runtime", + "sp-tracing 16.0.0", "substrate-prometheus-endpoint", "sysinfo", "thiserror", @@ -17602,7 +17596,6 @@ dependencies = [ "array-bytes", "assert_matches", "criterion", - "env_logger 0.11.3", "num_cpus", "parity-scale-codec", "parking_lot 0.12.3", @@ -18045,7 +18038,6 @@ name = "sc-rpc" version = "29.0.0" dependencies = [ "assert_matches", - "env_logger 0.11.3", "futures", "jsonrpsee", "log", @@ -18076,6 +18068,7 @@ dependencies = [ "sp-runtime", "sp-session", "sp-statement-store", + "sp-tracing 16.0.0", "sp-version", "substrate-test-runtime-client", "tokio", @@ -18291,7 +18284,6 @@ dependencies = [ name = "sc-statement-store" version = "10.0.0" dependencies = [ - "env_logger 0.11.3", "log", "parity-db", "parking_lot 0.12.3", @@ -18302,6 +18294,7 @@ dependencies = [ "sp-core", "sp-runtime", "sp-statement-store", + "sp-tracing 16.0.0", "substrate-prometheus-endpoint", "tempfile", "tokio", @@ -19456,7 +19449,6 @@ name = "snowbridge-outbound-queue-merkle-tree" version = "0.3.0" dependencies = [ "array-bytes", - "env_logger 0.11.3", "hex", "hex-literal", "parity-scale-codec", @@ -19464,6 +19456,7 @@ dependencies = [ "sp-core", "sp-crypto-hashing", "sp-runtime", + "sp-tracing 16.0.0", ] [[package]] @@ -22513,6 +22506,7 @@ dependencies = [ "sharded-slab", "smallvec", "thread_local", + "time", "tracing", "tracing-core", "tracing-log 0.2.0", @@ -24152,7 +24146,6 @@ dependencies = [ name = "xcm-runtime-apis" version = "0.1.0" dependencies = [ - "env_logger 0.11.3", "frame-executive", "frame-support", "frame-system", @@ -24165,6 +24158,7 @@ dependencies = [ "scale-info", "sp-api", "sp-io", + "sp-tracing 16.0.0", "sp-weights", "staging-xcm", "staging-xcm-builder", diff --git a/Cargo.toml b/Cargo.toml index 703e1ebbcf62..7ae7c3bd1811 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,9 +1,9 @@ [workspace.package] authors = ["Parity Technologies "] edition = "2021" -repository = "https://github.com/paritytech/polkadot-sdk.git" -license = "GPL-3.0-only" homepage = "https://paritytech.github.io/polkadot-sdk/" +license = "GPL-3.0-only" +repository = "https://github.com/paritytech/polkadot-sdk.git" [workspace] resolver = "2" @@ -547,29 +547,29 @@ unexpected_cfgs = { level = "warn", check-cfg = ['cfg(substrate_runtime)'] } [workspace.lints.clippy] all = { level = "allow", priority = 0 } -correctness = { level = "warn", priority = 1 } +bind_instead_of_map = { level = "allow", priority = 2 } # stylistic +borrowed-box = { level = "allow", priority = 2 } # Reasonable to fix this one complexity = { level = "warn", priority = 1 } +correctness = { level = "warn", priority = 1 } +default_constructed_unit_structs = { level = "allow", priority = 2 } # stylistic +derivable_impls = { level = "allow", priority = 2 } # false positives +eq_op = { level = "allow", priority = 2 } # In tests we test equality. +erasing_op = { level = "allow", priority = 2 } # E.g. 0 * DOLLARS +extra-unused-type-parameters = { level = "allow", priority = 2 } # stylistic +identity-op = { level = "allow", priority = 2 } # One case where we do 0 + if-same-then-else = { level = "allow", priority = 2 } -zero-prefixed-literal = { level = "allow", priority = 2 } # 00_1000_000 -type_complexity = { level = "allow", priority = 2 } # raison d'etre +needless-lifetimes = { level = "allow", priority = 2 } # generated code +needless_option_as_deref = { level = "allow", priority = 2 } # false positives nonminimal-bool = { level = "allow", priority = 2 } # maybe -borrowed-box = { level = "allow", priority = 2 } # Reasonable to fix this one +option-map-unit-fn = { level = "allow", priority = 2 } # stylistic +stable_sort_primitive = { level = "allow", priority = 2 } # prefer stable sort too-many-arguments = { level = "allow", priority = 2 } # (Turning this on would lead to) -needless-lifetimes = { level = "allow", priority = 2 } # generated code +type_complexity = { level = "allow", priority = 2 } # raison d'etre +unit_arg = { level = "allow", priority = 2 } # stylistic unnecessary_cast = { level = "allow", priority = 2 } # Types may change -identity-op = { level = "allow", priority = 2 } # One case where we do 0 + useless_conversion = { level = "allow", priority = 2 } # Types may change -unit_arg = { level = "allow", priority = 2 } # stylistic -option-map-unit-fn = { level = "allow", priority = 2 } # stylistic -bind_instead_of_map = { level = "allow", priority = 2 } # stylistic -erasing_op = { level = "allow", priority = 2 } # E.g. 0 * DOLLARS -eq_op = { level = "allow", priority = 2 } # In tests we test equality. while_immutable_condition = { level = "allow", priority = 2 } # false positives -needless_option_as_deref = { level = "allow", priority = 2 } # false positives -derivable_impls = { level = "allow", priority = 2 } # false positives -stable_sort_primitive = { level = "allow", priority = 2 } # prefer stable sort -extra-unused-type-parameters = { level = "allow", priority = 2 } # stylistic -default_constructed_unit_structs = { level = "allow", priority = 2 } # stylistic +zero-prefixed-literal = { level = "allow", priority = 2 } # 00_1000_000 [workspace.dependencies] Inflector = { version = "0.11.4" } @@ -729,7 +729,6 @@ either = { version = "1.8.1", default-features = false } emulated-integration-tests-common = { path = "cumulus/parachains/integration-tests/emulated/common", default-features = false } enumflags2 = { version = "0.7.7" } enumn = { version = "0.1.13" } -env_logger = { version = "0.11.3" } environmental = { version = "1.1.4", default-features = false } equivocation-detector = { path = "bridges/relays/equivocation" } ethabi = { version = "1.0.0", default-features = false, package = "ethabi-decode" } @@ -1358,22 +1357,22 @@ zstd = { version = "0.12.4", default-features = false } [profile.release] # Polkadot runtime requires unwinding. -panic = "unwind" opt-level = 3 +panic = "unwind" # make sure dev builds with backtrace do not slow us down [profile.dev.package.backtrace] inherits = "release" [profile.production] +codegen-units = 1 inherits = "release" lto = true -codegen-units = 1 [profile.testnet] -inherits = "release" debug = 1 # debug symbols are useful for profilers debug-assertions = true +inherits = "release" overflow-checks = true # The list of dependencies below (which can be both direct and indirect dependencies) are crates diff --git a/bridges/relays/utils/Cargo.toml b/bridges/relays/utils/Cargo.toml index 2c3f37750486..beb03b9381d4 100644 --- a/bridges/relays/utils/Cargo.toml +++ b/bridges/relays/utils/Cargo.toml @@ -17,7 +17,7 @@ async-trait = { workspace = true } backoff = { workspace = true } console = { workspace = true } isahc = { workspace = true } -env_logger = { workspace = true } +sp-tracing = { workspace = true, default-features = true } futures = { workspace = true } jsonpath_lib = { workspace = true } log = { workspace = true } diff --git a/bridges/relays/utils/src/initialize.rs b/bridges/relays/utils/src/initialize.rs index cd0377caa3d6..564ed1f0e5cc 100644 --- a/bridges/relays/utils/src/initialize.rs +++ b/bridges/relays/utils/src/initialize.rs @@ -16,9 +16,15 @@ //! Relayer initialization functions. -use console::style; use parking_lot::Mutex; -use std::{cell::RefCell, fmt::Display, io::Write}; +use sp_tracing::{ + tracing::Level, + tracing_subscriber::{ + fmt::{time::OffsetTime, SubscriberBuilder}, + EnvFilter, + }, +}; +use std::cell::RefCell; /// Relayer version that is provided as metric. Must be set by a binary /// (get it with `option_env!("CARGO_PKG_VERSION")` from a binary package code). @@ -41,101 +47,25 @@ pub fn initialize_logger(with_timestamp: bool) { ) .expect("static format string is valid"); - let mut builder = env_logger::Builder::new(); - builder.filter_level(log::LevelFilter::Warn); - builder.filter_module("bridge", log::LevelFilter::Info); - builder.parse_default_env(); - if with_timestamp { - builder.format(move |buf, record| { - let timestamp = time::OffsetDateTime::now_local() - .unwrap_or_else(|_| time::OffsetDateTime::now_utc()); - let timestamp = timestamp.format(&format).unwrap_or_else(|_| timestamp.to_string()); + let local_time = OffsetTime::new( + time::UtcOffset::current_local_offset().unwrap_or(time::UtcOffset::UTC), + format, + ); - let log_level = color_level(record.level()); - let log_target = color_target(record.target()); - let timestamp = if cfg!(windows) { - Either::Left(timestamp) - } else { - Either::Right(style(timestamp).black().bright().bold().to_string()) - }; + let env_filter = EnvFilter::from_default_env() + .add_directive(Level::WARN.into()) + .add_directive("bridge=info".parse().expect("static filter string is valid")); - writeln!( - buf, - "{}{} {} {} {}", - loop_name_prefix(), - timestamp, - log_level, - log_target, - record.args(), - ) - }); - } else { - builder.format(move |buf, record| { - let log_level = color_level(record.level()); - let log_target = color_target(record.target()); + let builder = SubscriberBuilder::default().with_env_filter(env_filter); - writeln!(buf, "{}{log_level} {log_target} {}", loop_name_prefix(), record.args(),) - }); + if with_timestamp { + builder.with_timer(local_time).init(); + } else { + builder.without_time().init(); } - - builder.init(); } /// Initialize relay loop. Must only be called once per every loop task. pub(crate) fn initialize_loop(loop_name: String) { LOOP_NAME.with(|g_loop_name| *g_loop_name.borrow_mut() = loop_name); } - -/// Returns loop name prefix to use in logs. The prefix is initialized with the `initialize_loop` -/// call. -fn loop_name_prefix() -> String { - // try_with to avoid panic outside of async-std task context - LOOP_NAME - .try_with(|loop_name| { - // using borrow is ok here, because loop is only initialized once (=> borrow_mut will - // only be called once) - let loop_name = loop_name.borrow(); - if loop_name.is_empty() { - String::new() - } else { - format!("[{loop_name}] ") - } - }) - .unwrap_or_else(|_| String::new()) -} - -enum Either { - Left(A), - Right(B), -} -impl Display for Either { - fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result { - match self { - Self::Left(a) => write!(fmt, "{a}"), - Self::Right(b) => write!(fmt, "{b}"), - } - } -} - -fn color_target(target: &str) -> impl Display + '_ { - if cfg!(windows) { - Either::Left(target) - } else { - Either::Right(style(target).black().bright().to_string()) - } -} - -fn color_level(level: log::Level) -> impl Display { - if cfg!(windows) { - Either::Left(level) - } else { - let s = level.to_string(); - Either::Right(match level { - log::Level::Error => style(s).red().bright().bold().to_string(), - log::Level::Warn => style(s).yellow().bright().bold().to_string(), - log::Level::Info => style(s).green().bright().to_string(), - log::Level::Debug => style(s).cyan().bright().to_string(), - log::Level::Trace => style(s).blue().bright().to_string(), - }) - } -} diff --git a/bridges/snowbridge/pallets/outbound-queue/merkle-tree/Cargo.toml b/bridges/snowbridge/pallets/outbound-queue/merkle-tree/Cargo.toml index 00cc700fbe83..9d4cffc98d78 100644 --- a/bridges/snowbridge/pallets/outbound-queue/merkle-tree/Cargo.toml +++ b/bridges/snowbridge/pallets/outbound-queue/merkle-tree/Cargo.toml @@ -23,10 +23,10 @@ sp-runtime = { workspace = true } [dev-dependencies] hex-literal = { workspace = true, default-features = true } -env_logger = { workspace = true } hex = { workspace = true, default-features = true } array-bytes = { workspace = true, default-features = true } sp-crypto-hashing = { workspace = true, default-features = true } +sp-tracing = { workspace = true, default-features = true } [features] default = ["std"] diff --git a/bridges/snowbridge/pallets/outbound-queue/merkle-tree/src/lib.rs b/bridges/snowbridge/pallets/outbound-queue/merkle-tree/src/lib.rs index 8c91ccd04d9a..d5c89b9c0987 100644 --- a/bridges/snowbridge/pallets/outbound-queue/merkle-tree/src/lib.rs +++ b/bridges/snowbridge/pallets/outbound-queue/merkle-tree/src/lib.rs @@ -335,7 +335,7 @@ mod tests { #[test] fn should_generate_empty_root() { // given - let _ = env_logger::try_init(); + sp_tracing::init_for_tests(); let data = vec![]; // when @@ -351,7 +351,7 @@ mod tests { #[test] fn should_generate_single_root() { // given - let _ = env_logger::try_init(); + sp_tracing::init_for_tests(); let data = make_leaves(1); // when @@ -367,7 +367,7 @@ mod tests { #[test] fn should_generate_root_pow_2() { // given - let _ = env_logger::try_init(); + sp_tracing::init_for_tests(); let data = make_leaves(2); // when @@ -382,7 +382,7 @@ mod tests { #[test] fn should_generate_root_complex() { - let _ = env_logger::try_init(); + sp_tracing::init_for_tests(); let test = |root, data: Vec| { assert_eq!( array_bytes::bytes2hex("", merkle_root::(data.into_iter()).as_ref()), @@ -401,7 +401,7 @@ mod tests { #[ignore] fn should_generate_and_verify_proof() { // given - let _ = env_logger::try_init(); + sp_tracing::init_for_tests(); let data: Vec = make_leaves(3); // when @@ -458,7 +458,7 @@ mod tests { #[test] #[should_panic] fn should_panic_on_invalid_leaf_index() { - let _ = env_logger::try_init(); + sp_tracing::init_for_tests(); merkle_proof::(make_leaves(1).into_iter(), 5); } } diff --git a/polkadot/node/core/approval-voting/Cargo.toml b/polkadot/node/core/approval-voting/Cargo.toml index 65985c0a5db9..bc0187bf4922 100644 --- a/polkadot/node/core/approval-voting/Cargo.toml +++ b/polkadot/node/core/approval-voting/Cargo.toml @@ -52,7 +52,7 @@ assert_matches = { workspace = true } kvdb-memorydb = { workspace = true } polkadot-primitives-test-helpers = { workspace = true } log = { workspace = true, default-features = true } -env_logger = { workspace = true } +sp-tracing = { workspace = true } polkadot-subsystem-bench = { workspace = true } diff --git a/polkadot/node/core/approval-voting/src/tests.rs b/polkadot/node/core/approval-voting/src/tests.rs index 64ae86bc013a..b912449baa4d 100644 --- a/polkadot/node/core/approval-voting/src/tests.rs +++ b/polkadot/node/core/approval-voting/src/tests.rs @@ -543,11 +543,7 @@ fn test_harness>( config: HarnessConfig, test: impl FnOnce(TestHarness) -> T, ) { - let _ = env_logger::builder() - .is_test(true) - .filter(Some("polkadot_node_core_approval_voting"), log::LevelFilter::Trace) - .filter(Some(LOG_TARGET), log::LevelFilter::Trace) - .try_init(); + sp_tracing::init_for_tests(); let HarnessConfig { sync_oracle, sync_oracle_handle, clock, backend, assignment_criteria } = config; diff --git a/polkadot/node/core/av-store/Cargo.toml b/polkadot/node/core/av-store/Cargo.toml index 4274c8b576a3..c867180e541b 100644 --- a/polkadot/node/core/av-store/Cargo.toml +++ b/polkadot/node/core/av-store/Cargo.toml @@ -29,9 +29,9 @@ polkadot-node-jaeger = { workspace = true, default-features = true } [dev-dependencies] log = { workspace = true, default-features = true } -env_logger = { workspace = true } assert_matches = { workspace = true } kvdb-memorydb = { workspace = true } +sp-tracing = { workspace = true } sp-core = { workspace = true, default-features = true } polkadot-node-subsystem-util = { workspace = true, default-features = true } diff --git a/polkadot/node/core/av-store/src/tests.rs b/polkadot/node/core/av-store/src/tests.rs index 04a223730bcd..958917a3104f 100644 --- a/polkadot/node/core/av-store/src/tests.rs +++ b/polkadot/node/core/av-store/src/tests.rs @@ -122,11 +122,7 @@ fn test_harness>( store: Arc, test: impl FnOnce(VirtualOverseer) -> T, ) { - let _ = env_logger::builder() - .is_test(true) - .filter(Some("polkadot_node_core_av_store"), log::LevelFilter::Trace) - .filter(Some(LOG_TARGET), log::LevelFilter::Trace) - .try_init(); + sp_tracing::init_for_tests(); let pool = sp_core::testing::TaskExecutor::new(); let (context, virtual_overseer) = diff --git a/polkadot/node/network/approval-distribution/Cargo.toml b/polkadot/node/network/approval-distribution/Cargo.toml index a85cde303b61..1bd3d51b5c93 100644 --- a/polkadot/node/network/approval-distribution/Cargo.toml +++ b/polkadot/node/network/approval-distribution/Cargo.toml @@ -37,5 +37,5 @@ schnorrkel = { workspace = true } # rand_core should match schnorrkel rand_core = { workspace = true } rand_chacha = { workspace = true, default-features = true } -env_logger = { workspace = true } +sp-tracing = { workspace = true } log = { workspace = true, default-features = true } diff --git a/polkadot/node/network/approval-distribution/src/tests.rs b/polkadot/node/network/approval-distribution/src/tests.rs index 2d08807f97b6..3ea722c51a92 100644 --- a/polkadot/node/network/approval-distribution/src/tests.rs +++ b/polkadot/node/network/approval-distribution/src/tests.rs @@ -50,10 +50,7 @@ fn test_harness>( mut state: State, test_fn: impl FnOnce(VirtualOverseer) -> T, ) -> State { - let _ = env_logger::builder() - .is_test(true) - .filter(Some(LOG_TARGET), log::LevelFilter::Trace) - .try_init(); + sp_tracing::init_for_tests(); let pool = sp_core::testing::TaskExecutor::new(); let (context, virtual_overseer) = diff --git a/polkadot/node/network/bitfield-distribution/Cargo.toml b/polkadot/node/network/bitfield-distribution/Cargo.toml index b1becaf319d5..6d007255c574 100644 --- a/polkadot/node/network/bitfield-distribution/Cargo.toml +++ b/polkadot/node/network/bitfield-distribution/Cargo.toml @@ -29,7 +29,6 @@ sp-authority-discovery = { workspace = true, default-features = true } sp-keystore = { workspace = true, default-features = true } sp-keyring = { workspace = true, default-features = true } maplit = { workspace = true } -log = { workspace = true, default-features = true } -env_logger = { workspace = true } +sp-tracing = { workspace = true } assert_matches = { workspace = true } rand_chacha = { workspace = true, default-features = true } diff --git a/polkadot/node/network/bitfield-distribution/src/tests.rs b/polkadot/node/network/bitfield-distribution/src/tests.rs index dc37f73ec8a1..4ed4bf6b38c5 100644 --- a/polkadot/node/network/bitfield-distribution/src/tests.rs +++ b/polkadot/node/network/bitfield-distribution/src/tests.rs @@ -137,10 +137,7 @@ fn state_with_view( #[test] fn receive_invalid_signature() { - let _ = env_logger::builder() - .filter(None, log::LevelFilter::Trace) - .is_test(true) - .try_init(); + sp_tracing::init_for_tests(); let hash_a: Hash = [0; 32].into(); @@ -254,10 +251,7 @@ fn receive_invalid_signature() { #[test] fn receive_invalid_validator_index() { - let _ = env_logger::builder() - .filter(None, log::LevelFilter::Trace) - .is_test(true) - .try_init(); + sp_tracing::init_for_tests(); let hash_a: Hash = [0; 32].into(); let hash_b: Hash = [1; 32].into(); // other @@ -317,10 +311,7 @@ fn receive_invalid_validator_index() { #[test] fn receive_duplicate_messages() { - let _ = env_logger::builder() - .filter(None, log::LevelFilter::Trace) - .is_test(true) - .try_init(); + sp_tracing::init_for_tests(); let hash_a: Hash = [0; 32].into(); let hash_b: Hash = [1; 32].into(); @@ -442,10 +433,7 @@ fn receive_duplicate_messages() { fn delay_reputation_change() { use polkadot_node_subsystem_util::reputation::add_reputation; - let _ = env_logger::builder() - .filter(None, log::LevelFilter::Trace) - .is_test(true) - .try_init(); + sp_tracing::init_for_tests(); let hash_a: Hash = [0; 32].into(); let hash_b: Hash = [1; 32].into(); @@ -550,10 +538,7 @@ fn delay_reputation_change() { #[test] fn do_not_relay_message_twice() { - let _ = env_logger::builder() - .filter(None, log::LevelFilter::Trace) - .is_test(true) - .try_init(); + sp_tracing::init_for_tests(); let hash = Hash::random(); @@ -658,10 +643,7 @@ fn do_not_relay_message_twice() { #[test] fn changing_view() { - let _ = env_logger::builder() - .filter(None, log::LevelFilter::Trace) - .is_test(true) - .try_init(); + sp_tracing::init_for_tests(); let hash_a: Hash = [0; 32].into(); let hash_b: Hash = [1; 32].into(); @@ -833,10 +815,7 @@ fn changing_view() { #[test] fn do_not_send_message_back_to_origin() { - let _ = env_logger::builder() - .filter(None, log::LevelFilter::Trace) - .is_test(true) - .try_init(); + sp_tracing::init_for_tests(); let hash: Hash = [0; 32].into(); @@ -920,10 +899,7 @@ fn do_not_send_message_back_to_origin() { #[test] fn topology_test() { - let _ = env_logger::builder() - .filter(None, log::LevelFilter::Trace) - .is_test(true) - .try_init(); + sp_tracing::init_for_tests(); let hash: Hash = [0; 32].into(); diff --git a/polkadot/node/network/collator-protocol/Cargo.toml b/polkadot/node/network/collator-protocol/Cargo.toml index d41fc7ebe8dd..8a7c384dcbe8 100644 --- a/polkadot/node/network/collator-protocol/Cargo.toml +++ b/polkadot/node/network/collator-protocol/Cargo.toml @@ -29,8 +29,7 @@ thiserror = { workspace = true } tokio-util = { workspace = true } [dev-dependencies] -log = { workspace = true, default-features = true } -env_logger = { workspace = true } +sp-tracing = { workspace = true } assert_matches = { workspace = true } rstest = { workspace = true } diff --git a/polkadot/node/network/collator-protocol/src/collator_side/tests/mod.rs b/polkadot/node/network/collator-protocol/src/collator_side/tests/mod.rs index 13601ca7a005..74a151c168dc 100644 --- a/polkadot/node/network/collator-protocol/src/collator_side/tests/mod.rs +++ b/polkadot/node/network/collator-protocol/src/collator_side/tests/mod.rs @@ -239,11 +239,7 @@ fn test_harness>( reputation: ReputationAggregator, test: impl FnOnce(TestHarness) -> T, ) { - let _ = env_logger::builder() - .is_test(true) - .filter(Some("polkadot_collator_protocol"), log::LevelFilter::Trace) - .filter(Some(LOG_TARGET), log::LevelFilter::Trace) - .try_init(); + let _ = sp_tracing::init_for_tests(); let pool = sp_core::testing::TaskExecutor::new(); diff --git a/polkadot/node/network/collator-protocol/src/validator_side/tests/mod.rs b/polkadot/node/network/collator-protocol/src/validator_side/tests/mod.rs index 44e25efd4dfc..86c8bcb6bdcd 100644 --- a/polkadot/node/network/collator-protocol/src/validator_side/tests/mod.rs +++ b/polkadot/node/network/collator-protocol/src/validator_side/tests/mod.rs @@ -156,11 +156,7 @@ fn test_harness>( reputation: ReputationAggregator, test: impl FnOnce(TestHarness) -> T, ) { - let _ = env_logger::builder() - .is_test(true) - .filter(Some("polkadot_collator_protocol"), log::LevelFilter::Trace) - .filter(Some(LOG_TARGET), log::LevelFilter::Trace) - .try_init(); + sp_tracing::init_for_tests(); let pool = sp_core::testing::TaskExecutor::new(); diff --git a/polkadot/node/service/Cargo.toml b/polkadot/node/service/Cargo.toml index c0ddbf7dcfc3..216aa10e8acb 100644 --- a/polkadot/node/service/Cargo.toml +++ b/polkadot/node/service/Cargo.toml @@ -149,7 +149,7 @@ xcm-runtime-apis = { workspace = true, default-features = true } polkadot-test-client = { workspace = true } polkadot-node-subsystem-test-helpers = { workspace = true } polkadot-primitives-test-helpers = { workspace = true } -env_logger = { workspace = true } +sp-tracing = { workspace = true } assert_matches = { workspace = true } serial_test = { workspace = true } tempfile = { workspace = true } diff --git a/polkadot/node/service/src/tests.rs b/polkadot/node/service/src/tests.rs index bebd05071013..195432bcb75d 100644 --- a/polkadot/node/service/src/tests.rs +++ b/polkadot/node/service/src/tests.rs @@ -70,10 +70,7 @@ fn test_harness>( case_vars: CaseVars, test: impl FnOnce(TestHarness) -> T, ) { - let _ = env_logger::builder() - .is_test(true) - .filter_level(log::LevelFilter::Trace) - .try_init(); + sp_tracing::init_for_tests(); let pool = TaskExecutor::new(); let (mut context, virtual_overseer) = diff --git a/polkadot/node/subsystem-bench/Cargo.toml b/polkadot/node/subsystem-bench/Cargo.toml index 0325613d25f9..9384f8142a97 100644 --- a/polkadot/node/subsystem-bench/Cargo.toml +++ b/polkadot/node/subsystem-bench/Cargo.toml @@ -49,7 +49,7 @@ hex = { workspace = true, default-features = true } gum = { workspace = true, default-features = true } polkadot-erasure-coding = { workspace = true, default-features = true } log = { workspace = true, default-features = true } -env_logger = { workspace = true } +sp-tracing = { workspace = true } rand = { workspace = true, default-features = true } # `rand` only supports uniform distribution, we need normal distribution for latency. rand_distr = { workspace = true } diff --git a/polkadot/node/subsystem-bench/src/cli/subsystem-bench.rs b/polkadot/node/subsystem-bench/src/cli/subsystem-bench.rs index 346a058b9796..153efdda4056 100644 --- a/polkadot/node/subsystem-bench/src/cli/subsystem-bench.rs +++ b/polkadot/node/subsystem-bench/src/cli/subsystem-bench.rs @@ -184,14 +184,7 @@ impl BenchCli { fn main() -> eyre::Result<()> { color_eyre::install()?; - env_logger::builder() - .filter(Some("hyper"), log::LevelFilter::Info) - // Avoid `Terminating due to subsystem exit subsystem` warnings - .filter(Some("polkadot_overseer"), log::LevelFilter::Error) - .filter(None, log::LevelFilter::Info) - .format_timestamp_millis() - .try_init() - .unwrap(); + sp_tracing::try_init_simple(); let cli: BenchCli = BenchCli::parse(); cli.launch()?; diff --git a/polkadot/node/subsystem-util/Cargo.toml b/polkadot/node/subsystem-util/Cargo.toml index 98ea21f250ed..a7157d1b5b7f 100644 --- a/polkadot/node/subsystem-util/Cargo.toml +++ b/polkadot/node/subsystem-util/Cargo.toml @@ -45,7 +45,6 @@ parity-db = { workspace = true } [dev-dependencies] assert_matches = { workspace = true } -env_logger = { workspace = true } futures = { features = ["thread-pool"], workspace = true } log = { workspace = true, default-features = true } polkadot-node-subsystem-test-helpers = { workspace = true } diff --git a/polkadot/xcm/xcm-runtime-apis/Cargo.toml b/polkadot/xcm/xcm-runtime-apis/Cargo.toml index 748d5af68a1f..9ccca76c321c 100644 --- a/polkadot/xcm/xcm-runtime-apis/Cargo.toml +++ b/polkadot/xcm/xcm-runtime-apis/Cargo.toml @@ -31,7 +31,7 @@ pallet-assets = { workspace = true } xcm-executor = { workspace = true } frame-executive = { workspace = true } log = { workspace = true } -env_logger = { workspace = true } +sp-tracing = { workspace = true, default-features = true } [features] default = ["std"] diff --git a/polkadot/xcm/xcm-runtime-apis/tests/fee_estimation.rs b/polkadot/xcm/xcm-runtime-apis/tests/fee_estimation.rs index 59ee17973805..e5dac7c7a04e 100644 --- a/polkadot/xcm/xcm-runtime-apis/tests/fee_estimation.rs +++ b/polkadot/xcm/xcm-runtime-apis/tests/fee_estimation.rs @@ -41,7 +41,7 @@ use mock::{ // Parachain(2000) -------------------------------------------> Parachain(1000) #[test] fn fee_estimation_for_teleport() { - let _ = env_logger::builder().is_test(true).try_init(); + sp_tracing::init_for_tests(); let who = 1; // AccountId = u64. let balances = vec![(who, 100 + DeliveryFees::get() + ExistentialDeposit::get())]; let assets = vec![(1, who, 50)]; @@ -195,7 +195,7 @@ fn fee_estimation_for_teleport() { // Parachain(2000) -------------------------------------------> Parachain(1000) #[test] fn dry_run_reserve_asset_transfer() { - let _ = env_logger::builder().is_test(true).try_init(); + sp_tracing::init_for_tests(); let who = 1; // AccountId = u64. // Native token used for fees. let balances = vec![(who, DeliveryFees::get() + ExistentialDeposit::get())]; @@ -274,7 +274,7 @@ fn dry_run_reserve_asset_transfer() { #[test] fn dry_run_xcm() { - let _ = env_logger::builder().is_test(true).try_init(); + sp_tracing::init_for_tests(); let who = 1; // AccountId = u64. let transfer_amount = 100u128; // We need to build the XCM to weigh it and then build the real XCM that can pay for fees. diff --git a/prdoc/pr_5065.prdoc b/prdoc/pr_5065.prdoc new file mode 100644 index 000000000000..11fca2ab71d6 --- /dev/null +++ b/prdoc/pr_5065.prdoc @@ -0,0 +1,65 @@ +# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 +# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json + +title: Replace env_logger with sp_tracing + +doc: + - audience: Node Dev + description: | + This PR replaces env_logger with sp_tracing because of an issue with env_logger and gum #4660 + +crates: + - name: relay-utils + bump: none + - name: snowbridge-outbound-queue-merkle-tree + bump: patch + - name: polkadot-node-core-approval-voting + bump: patch + - name: polkadot-node-core-av-store + bump: patch + - name: polkadot-approval-distribution + bump: patch + - name: polkadot-availability-bitfield-distribution + bump: patch + - name: polkadot-collator-protocol + bump: patch + - name: polkadot-service + bump: patch + - name: polkadot-subsystem-bench + bump: none + - name: polkadot-node-subsystem-util + bump: none + - name: xcm-runtime-apis + bump: patch + - name: sc-executor + bump: patch + - name: sc-rpc + bump: patch + - name: sc-statement-store + bump: patch + - name: pallet-contracts + bump: patch + - name: pallet-mmr + bump: patch + - name: sp-tracing + bump: patch + - name: binary-merkle-tree + bump: patch + - name: frame-omni-bencher + bump: patch + - name: pallet-balances + bump: patch + - name: pallet-staking + bump: patch + - name: pallet-treasury + bump: patch + - name: pallet-bounties + bump: patch + - name: pallet-conviction-voting + bump: patch + - name: pallet-democracy + bump: patch + - name: pallet-elections-phragmen + bump: patch + - name: pallet-referenda + bump: patch \ No newline at end of file diff --git a/substrate/client/executor/Cargo.toml b/substrate/client/executor/Cargo.toml index 2c24663bccca..ca78afd47068 100644 --- a/substrate/client/executor/Cargo.toml +++ b/substrate/client/executor/Cargo.toml @@ -51,7 +51,6 @@ tracing-subscriber = { workspace = true } paste = { workspace = true, default-features = true } regex = { workspace = true } criterion = { workspace = true, default-features = true } -env_logger = { workspace = true } num_cpus = { workspace = true } tempfile = { workspace = true } diff --git a/substrate/client/executor/benches/bench.rs b/substrate/client/executor/benches/bench.rs index 86c769f88811..4cde8c2a4a64 100644 --- a/substrate/client/executor/benches/bench.rs +++ b/substrate/client/executor/benches/bench.rs @@ -147,7 +147,7 @@ fn run_benchmark( } fn bench_call_instance(c: &mut Criterion) { - let _ = env_logger::try_init(); + sp_tracing::try_init_simple(); let strategies = [ ( diff --git a/substrate/client/rpc/Cargo.toml b/substrate/client/rpc/Cargo.toml index e8d9ad4948d7..4a8f4b3ec630 100644 --- a/substrate/client/rpc/Cargo.toml +++ b/substrate/client/rpc/Cargo.toml @@ -43,7 +43,7 @@ sp-statement-store = { workspace = true, default-features = true } tokio = { workspace = true, default-features = true } [dev-dependencies] -env_logger = { workspace = true } +sp-tracing = { workspace = true } assert_matches = { workspace = true } sc-block-builder = { workspace = true, default-features = true } sc-network = { workspace = true, default-features = true } diff --git a/substrate/client/rpc/src/author/tests.rs b/substrate/client/rpc/src/author/tests.rs index 937870eb53fd..6bcb3e7863c0 100644 --- a/substrate/client/rpc/src/author/tests.rs +++ b/substrate/client/rpc/src/author/tests.rs @@ -89,7 +89,7 @@ impl TestSetup { #[tokio::test] async fn author_submit_transaction_should_not_cause_error() { - let _ = env_logger::try_init(); + sp_tracing::init_for_tests(); let author = TestSetup::default().author(); let api = author.into_rpc(); let xt: Bytes = uxt(AccountKeyring::Alice, 1).encode().into(); @@ -279,7 +279,7 @@ async fn author_has_session_keys() { #[tokio::test] async fn author_has_key() { - let _ = env_logger::try_init(); + sp_tracing::init_for_tests(); let api = TestSetup::into_rpc(); let suri = "//Alice"; diff --git a/substrate/client/statement-store/Cargo.toml b/substrate/client/statement-store/Cargo.toml index ef0bfc548673..e5087eae6eca 100644 --- a/substrate/client/statement-store/Cargo.toml +++ b/substrate/client/statement-store/Cargo.toml @@ -31,4 +31,4 @@ sc-keystore = { workspace = true, default-features = true } [dev-dependencies] tempfile = { workspace = true } -env_logger = { workspace = true } +sp-tracing = { workspace = true } diff --git a/substrate/client/statement-store/src/lib.rs b/substrate/client/statement-store/src/lib.rs index da0af08b4540..799246a96188 100644 --- a/substrate/client/statement-store/src/lib.rs +++ b/substrate/client/statement-store/src/lib.rs @@ -1022,7 +1022,7 @@ mod tests { } fn test_store() -> (Store, tempfile::TempDir) { - let _ = env_logger::try_init(); + sp_tracing::init_for_tests(); let temp_dir = tempfile::Builder::new().tempdir().expect("Error creating test dir"); let client = std::sync::Arc::new(TestClient); diff --git a/substrate/frame/contracts/Cargo.toml b/substrate/frame/contracts/Cargo.toml index 1aa3d3513a7e..316ea6813048 100644 --- a/substrate/frame/contracts/Cargo.toml +++ b/substrate/frame/contracts/Cargo.toml @@ -58,7 +58,6 @@ xcm-builder = { workspace = true } [dev-dependencies] array-bytes = { workspace = true, default-features = true } assert_matches = { workspace = true } -env_logger = { workspace = true } pretty_assertions = { workspace = true } wat = { workspace = true } pallet-contracts-fixtures = { workspace = true } diff --git a/substrate/frame/contracts/src/tests.rs b/substrate/frame/contracts/src/tests.rs index cc2a69b5c419..c3b6e3273f34 100644 --- a/substrate/frame/contracts/src/tests.rs +++ b/substrate/frame/contracts/src/tests.rs @@ -549,9 +549,7 @@ impl ExtBuilder { self } pub fn build(self) -> sp_io::TestExternalities { - use env_logger::{Builder, Env}; - let env = Env::new().default_filter_or("runtime=debug"); - let _ = Builder::from_env(env).is_test(true).try_init(); + sp_tracing::try_init_simple(); self.set_associated_consts(); let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![] } diff --git a/substrate/frame/merkle-mountain-range/Cargo.toml b/substrate/frame/merkle-mountain-range/Cargo.toml index e8b00f6e56cb..4daa394a82d7 100644 --- a/substrate/frame/merkle-mountain-range/Cargo.toml +++ b/substrate/frame/merkle-mountain-range/Cargo.toml @@ -28,7 +28,7 @@ sp-runtime = { workspace = true } [dev-dependencies] array-bytes = { workspace = true, default-features = true } -env_logger = { workspace = true } +sp-tracing = { workspace = true, default-features = true } itertools = { workspace = true } [features] diff --git a/substrate/frame/merkle-mountain-range/src/tests.rs b/substrate/frame/merkle-mountain-range/src/tests.rs index b8c9d54db820..93e3d06eaa0a 100644 --- a/substrate/frame/merkle-mountain-range/src/tests.rs +++ b/substrate/frame/merkle-mountain-range/src/tests.rs @@ -81,7 +81,7 @@ fn add_blocks(blocks: usize) { #[test] fn should_start_empty() { - let _ = env_logger::try_init(); + sp_tracing::init_for_tests(); new_test_ext().execute_with(|| { // given assert_eq!( @@ -112,7 +112,7 @@ fn should_start_empty() { #[test] fn should_append_to_mmr_when_on_initialize_is_called() { - let _ = env_logger::try_init(); + sp_tracing::init_for_tests(); let mut ext = new_test_ext(); let (parent_b1, parent_b2) = ext.execute_with(|| { // when @@ -191,7 +191,7 @@ fn should_append_to_mmr_when_on_initialize_is_called() { #[test] fn should_construct_larger_mmr_correctly() { - let _ = env_logger::try_init(); + sp_tracing::init_for_tests(); new_test_ext().execute_with(|| { // when add_blocks(7); @@ -222,7 +222,7 @@ fn should_construct_larger_mmr_correctly() { #[test] fn should_calculate_the_size_correctly() { - let _ = env_logger::try_init(); + sp_tracing::init_for_tests(); let leaves = vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 21]; let sizes = vec![0, 1, 3, 4, 7, 8, 10, 11, 15, 16, 18, 19, 22, 23, 25, 26, 39]; @@ -243,7 +243,7 @@ fn should_calculate_the_size_correctly() { #[test] fn should_generate_proofs_correctly() { - let _ = env_logger::try_init(); + sp_tracing::init_for_tests(); let mut ext = new_test_ext(); // given let num_blocks: u64 = 7; @@ -418,7 +418,7 @@ fn should_generate_proofs_correctly() { #[test] fn should_generate_batch_proof_correctly() { - let _ = env_logger::try_init(); + sp_tracing::init_for_tests(); let mut ext = new_test_ext(); // given ext.execute_with(|| add_blocks(7)); @@ -471,7 +471,7 @@ fn should_generate_batch_proof_correctly() { #[test] fn should_verify() { - let _ = env_logger::try_init(); + sp_tracing::init_for_tests(); // Start off with chain initialisation and storing indexing data off-chain // (MMR Leafs) @@ -550,7 +550,7 @@ fn generate_and_verify_batch_proof( #[test] fn should_verify_batch_proofs() { - let _ = env_logger::try_init(); + sp_tracing::init_for_tests(); use itertools::Itertools; @@ -598,7 +598,7 @@ fn should_verify_batch_proofs() { #[test] fn verification_should_be_stateless() { - let _ = env_logger::try_init(); + sp_tracing::init_for_tests(); // Start off with chain initialisation and storing indexing data off-chain // (MMR Leafs) @@ -646,7 +646,7 @@ fn verification_should_be_stateless() { #[test] fn should_verify_batch_proof_statelessly() { - let _ = env_logger::try_init(); + sp_tracing::init_for_tests(); // Start off with chain initialisation and storing indexing data off-chain // (MMR Leafs) @@ -699,7 +699,7 @@ fn should_verify_batch_proof_statelessly() { #[test] fn should_verify_on_the_next_block_since_there_is_no_pruning_yet() { - let _ = env_logger::try_init(); + sp_tracing::init_for_tests(); let mut ext = new_test_ext(); // given ext.execute_with(|| add_blocks(7)); @@ -720,7 +720,7 @@ fn should_verify_on_the_next_block_since_there_is_no_pruning_yet() { #[test] fn should_verify_canonicalized() { use frame_support::traits::Hooks; - let _ = env_logger::try_init(); + sp_tracing::init_for_tests(); // How deep is our fork-aware storage (in terms of blocks/leaves, nodes will be more). let block_hash_size: u64 = ::BlockHashCount::get(); @@ -760,7 +760,7 @@ fn should_verify_canonicalized() { #[test] fn does_not_panic_when_generating_historical_proofs() { - let _ = env_logger::try_init(); + sp_tracing::init_for_tests(); let mut ext = new_test_ext(); // given 7 blocks (7 MMR leaves) @@ -790,7 +790,7 @@ fn does_not_panic_when_generating_historical_proofs() { #[test] fn generating_and_verifying_ancestry_proofs_works_correctly() { - let _ = env_logger::try_init(); + sp_tracing::init_for_tests(); let mut ext = new_test_ext(); let mut prev_roots = vec![]; diff --git a/substrate/frame/sassafras/src/tests.rs b/substrate/frame/sassafras/src/tests.rs index ec3425cce7bf..b3dc1ebed865 100644 --- a/substrate/frame/sassafras/src/tests.rs +++ b/substrate/frame/sassafras/src/tests.rs @@ -788,7 +788,6 @@ fn trivial_fisher_yates_shuffle(vector: &mut Vec, random_seed: u64) { #[test] fn submit_tickets_with_ring_proof_check_works() { use sp_core::Pair as _; - // env_logger::init(); let (authorities, mut tickets): (Vec, Vec) = data_read(TICKETS_FILE); diff --git a/substrate/primitives/tracing/Cargo.toml b/substrate/primitives/tracing/Cargo.toml index 7874338aa616..8621582c7654 100644 --- a/substrate/primitives/tracing/Cargo.toml +++ b/substrate/primitives/tracing/Cargo.toml @@ -21,13 +21,12 @@ features = ["with-tracing"] targets = ["wasm32-unknown-unknown", "x86_64-unknown-linux-gnu"] [dependencies] -codec = { features = [ - "derive", -], workspace = true } +codec = { features = ["derive"], workspace = true } tracing = { workspace = true } tracing-core = { workspace = true } tracing-subscriber = { workspace = true, optional = true, features = [ "env-filter", + "time", "tracing-log", ] } diff --git a/substrate/primitives/tracing/src/lib.rs b/substrate/primitives/tracing/src/lib.rs index 34ed088aed0b..21bba52d07ca 100644 --- a/substrate/primitives/tracing/src/lib.rs +++ b/substrate/primitives/tracing/src/lib.rs @@ -40,12 +40,15 @@ extern crate alloc; #[cfg(feature = "std")] -use tracing; +pub use tracing; pub use tracing::{ debug, debug_span, error, error_span, event, info, info_span, span, trace, trace_span, warn, warn_span, Level, Span, }; +#[cfg(feature = "std")] +pub use tracing_subscriber; + pub use crate::types::{ WasmEntryAttributes, WasmFieldName, WasmFields, WasmLevel, WasmMetadata, WasmValue, WasmValuesSet, diff --git a/substrate/utils/binary-merkle-tree/Cargo.toml b/substrate/utils/binary-merkle-tree/Cargo.toml index 5f7e80549aa4..087ec5fd6c6d 100644 --- a/substrate/utils/binary-merkle-tree/Cargo.toml +++ b/substrate/utils/binary-merkle-tree/Cargo.toml @@ -18,7 +18,7 @@ hash-db = { workspace = true } [dev-dependencies] array-bytes = { workspace = true, default-features = true } -env_logger = { workspace = true } +sp-tracing = { workspace = true, default-features = true } sp-core = { workspace = true, default-features = true } sp-runtime = { workspace = true, default-features = true } diff --git a/substrate/utils/binary-merkle-tree/src/lib.rs b/substrate/utils/binary-merkle-tree/src/lib.rs index 0efab9186c25..030e9f69b9b6 100644 --- a/substrate/utils/binary-merkle-tree/src/lib.rs +++ b/substrate/utils/binary-merkle-tree/src/lib.rs @@ -356,7 +356,7 @@ mod tests { #[test] fn should_generate_empty_root() { // given - let _ = env_logger::try_init(); + sp_tracing::init_for_tests(); let data: Vec<[u8; 1]> = Default::default(); // when @@ -372,7 +372,7 @@ mod tests { #[test] fn should_generate_single_root() { // given - let _ = env_logger::try_init(); + sp_tracing::init_for_tests(); let data = vec![array_bytes::hex2array_unchecked::<_, 20>( "E04CC55ebEE1cBCE552f250e85c57B70B2E2625b", )]; @@ -390,7 +390,7 @@ mod tests { #[test] fn should_generate_root_pow_2() { // given - let _ = env_logger::try_init(); + sp_tracing::init_for_tests(); let data = vec![ array_bytes::hex2array_unchecked::<_, 20>("E04CC55ebEE1cBCE552f250e85c57B70B2E2625b"), array_bytes::hex2array_unchecked::<_, 20>("25451A4de12dcCc2D166922fA938E900fCc4ED24"), @@ -408,7 +408,7 @@ mod tests { #[test] fn should_generate_root_complex() { - let _ = env_logger::try_init(); + sp_tracing::init_for_tests(); let test = |root, data| { assert_eq!(array_bytes::bytes2hex("", &merkle_root::(data)), root); }; @@ -437,7 +437,7 @@ mod tests { #[test] fn should_generate_and_verify_proof_simple() { // given - let _ = env_logger::try_init(); + sp_tracing::init_for_tests(); let data = vec!["a", "b", "c"]; // when @@ -501,7 +501,7 @@ mod tests { #[test] fn should_generate_and_verify_proof_complex() { // given - let _ = env_logger::try_init(); + sp_tracing::init_for_tests(); let data = vec!["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]; for l in 0..data.len() { @@ -521,7 +521,7 @@ mod tests { #[test] fn should_generate_and_verify_proof_large() { // given - let _ = env_logger::try_init(); + sp_tracing::init_for_tests(); let mut data = vec![]; for i in 1..16 { for c in 'a'..'z' { @@ -548,7 +548,7 @@ mod tests { #[test] fn should_generate_and_verify_proof_large_tree() { // given - let _ = env_logger::try_init(); + sp_tracing::init_for_tests(); let mut data = vec![]; for i in 0..6000 { data.push(format!("{}", i)); @@ -571,7 +571,7 @@ mod tests { #[test] #[should_panic] fn should_panic_on_invalid_leaf_index() { - let _ = env_logger::try_init(); + sp_tracing::init_for_tests(); merkle_proof::(vec!["a"], 5); } diff --git a/substrate/utils/frame/omni-bencher/Cargo.toml b/substrate/utils/frame/omni-bencher/Cargo.toml index f8f44cb4b438..89ef2a48e01d 100644 --- a/substrate/utils/frame/omni-bencher/Cargo.toml +++ b/substrate/utils/frame/omni-bencher/Cargo.toml @@ -17,5 +17,5 @@ frame-benchmarking-cli = { workspace = true } sc-cli = { workspace = true, default-features = true } sp-runtime = { workspace = true, default-features = true } sp-statement-store = { workspace = true, default-features = true } -env_logger = { workspace = true } +sp-tracing = { workspace = true } log = { workspace = true } diff --git a/substrate/utils/frame/omni-bencher/src/main.rs b/substrate/utils/frame/omni-bencher/src/main.rs index c148403f2970..a8893b5a79af 100644 --- a/substrate/utils/frame/omni-bencher/src/main.rs +++ b/substrate/utils/frame/omni-bencher/src/main.rs @@ -18,11 +18,10 @@ mod command; use clap::Parser; -use env_logger::Env; use sc_cli::Result; fn main() -> Result<()> { - env_logger::Builder::from_env(Env::default().default_filter_or("info")).init(); + sp_tracing::try_init_simple(); log::warn!("The FRAME omni-bencher is not yet battle tested - double check the results.",); command::Command::parse().run()