From 4b5adae78c099e6661579f8d38cb3c4e6a85b212 Mon Sep 17 00:00:00 2001 From: ascjones Date: Thu, 12 May 2022 10:04:36 +0100 Subject: [PATCH 1/9] Replace log with tracing for integration tests --- integration-tests/Cargo.toml | 3 ++- integration-tests/src/frame/contracts.rs | 15 ++++++++------- integration-tests/src/utils/node_proc.rs | 6 +++--- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index ea49dbe465..2a15ac50a6 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -22,7 +22,6 @@ env_logger = "0.9.0" frame-metadata = "15.0.0" futures = "0.3.13" hex = "0.4.3" -log = "0.4.14" scale-info = { version = "2.0.0", features = ["bit-vec"] } sp-core = { version = "6.0.0", default-features = false } sp-keyring = "6.0.0" @@ -30,5 +29,7 @@ sp-runtime = "6.0.0" subxt = { version = "0.21.0", path = "../subxt" } test-runtime = { path = "../test-runtime" } tokio = { version = "1.8", features = ["macros", "time"] } +tracing = "0.1.34" +tracing-subscriber = "0.3.11" wabt = "0.10.0" which = "4.0.2" diff --git a/integration-tests/src/frame/contracts.rs b/integration-tests/src/frame/contracts.rs index 944d33779b..8849180c3d 100644 --- a/integration-tests/src/frame/contracts.rs +++ b/integration-tests/src/frame/contracts.rs @@ -52,6 +52,7 @@ type AccountId = ::AccountId; impl ContractsTestContext { async fn init() -> Self { + let _ = tracing_subscriber::fmt::try_init(); let cxt = test_context().await; let signer = PairSigner::new(AccountKeyring::Alice.pair()); @@ -69,7 +70,7 @@ impl ContractsTestContext { async fn instantiate_with_code( &self, ) -> Result<(Hash, AccountId), Error> { - log::info!("instantiate_with_code:"); + tracing::info!("instantiate_with_code:"); const CONTRACT: &str = r#" (module (func (export "call")) @@ -108,9 +109,9 @@ impl ContractsTestContext { Error::Other("Failed to find a ExtrinsicSuccess event".into()) })?; - log::info!(" Block hash: {:?}", events.block_hash()); - log::info!(" Code hash: {:?}", code_stored.code_hash); - log::info!(" Contract address: {:?}", instantiated.contract); + tracing::info!(" Block hash: {:?}", events.block_hash()); + tracing::info!(" Code hash: {:?}", code_stored.code_hash); + tracing::info!(" Contract address: {:?}", instantiated.contract); Ok((code_stored.code_hash, instantiated.contract)) } @@ -136,7 +137,7 @@ impl ContractsTestContext { .wait_for_finalized_success() .await?; - log::info!("Instantiate result: {:?}", result); + tracing::info!("Instantiate result: {:?}", result); let instantiated = result .find_first::()? .ok_or_else(|| Error::Other("Failed to find a Instantiated event".into()))?; @@ -152,7 +153,7 @@ impl ContractsTestContext { TransactionProgress<'_, DefaultConfig, DispatchError, node_runtime::Event>, Error, > { - log::info!("call: {:?}", contract); + tracing::info!("call: {:?}", contract); let result = self .contracts_tx() .call( @@ -165,7 +166,7 @@ impl ContractsTestContext { .sign_and_submit_then_watch_default(&self.signer) .await?; - log::info!("Call result: {:?}", result); + tracing::info!("Call result: {:?}", result); Ok(result) } } diff --git a/integration-tests/src/utils/node_proc.rs b/integration-tests/src/utils/node_proc.rs index 16e5d8887f..33488de22b 100644 --- a/integration-tests/src/utils/node_proc.rs +++ b/integration-tests/src/utils/node_proc.rs @@ -63,10 +63,10 @@ where /// Attempt to kill the running substrate process. pub fn kill(&mut self) -> Result<(), String> { - log::info!("Killing node process {}", self.proc.id()); + tracing::info!("Killing node process {}", self.proc.id()); if let Err(err) = self.proc.kill() { let err = format!("Error killing node process {}: {}", self.proc.id(), err); - log::error!("{}", err); + tracing::error!("{}", err); return Err(err) } Ok(()) @@ -152,7 +152,7 @@ impl TestNodeProcessBuilder { } Err(err) => { let err = format!("Failed to connect to node rpc at {}: {}", ws_url, err); - log::error!("{}", err); + tracing::error!("{}", err); proc.kill().map_err(|e| { format!("Error killing substrate process '{}': {}", proc.id(), e) })?; From 3721f783b2480e0cd8477852feef598d6bcf6f6f Mon Sep 17 00:00:00 2001 From: ascjones Date: Thu, 12 May 2022 10:06:03 +0100 Subject: [PATCH 2/9] Replace log with tracing --- subxt/Cargo.toml | 2 +- subxt/src/events/events_type.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/subxt/Cargo.toml b/subxt/Cargo.toml index 5a2017941e..eed8dda2c1 100644 --- a/subxt/Cargo.toml +++ b/subxt/Cargo.toml @@ -25,10 +25,10 @@ scale-info = { version = "2.0.0", features = ["bit-vec"] } futures = "0.3.13" hex = "0.4.3" jsonrpsee = { version = "0.12.0", features = ["async-client", "client-ws-transport"] } -log = "0.4.14" serde = { version = "1.0.124", features = ["derive"] } serde_json = "1.0.64" thiserror = "1.0.24" +trace = "0.1.6" parking_lot = "0.12.0" subxt-macro = { version = "0.21.0", path = "../macro" } diff --git a/subxt/src/events/events_type.rs b/subxt/src/events/events_type.rs index 493856c3bb..c5a902a3f5 100644 --- a/subxt/src/events/events_type.rs +++ b/subxt/src/events/events_type.rs @@ -339,17 +339,17 @@ fn decode_raw_event_details( let phase = Phase::decode(input)?; let pallet_index = input.read_byte()?; let variant_index = input.read_byte()?; - log::debug!( + tracing::debug!( "phase {:?}, pallet_index {}, event_variant: {}", phase, pallet_index, variant_index ); - log::debug!("remaining input: {}", hex::encode(&input)); + tracing::debug!("remaining input: {}", hex::encode(&input)); // Get metadata for the event: let event_metadata = metadata.event(pallet_index, variant_index)?; - log::debug!( + tracing::debug!( "Decoding Event '{}::{}'", event_metadata.pallet(), event_metadata.event() @@ -375,7 +375,7 @@ fn decode_raw_event_details( // topics come after the event data in EventRecord. They aren't used for // anything at the moment, so just decode and throw them away. let topics = Vec::::decode(input)?; - log::debug!("topics: {:?}", topics); + tracing::debug!("topics: {:?}", topics); Ok(RawEventDetails { phase, From 6411efec44d7a131e9d07d39a682fcf0ca834a87 Mon Sep 17 00:00:00 2001 From: ascjones Date: Thu, 12 May 2022 10:45:01 +0100 Subject: [PATCH 3/9] Use correct tracing lib --- subxt/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subxt/Cargo.toml b/subxt/Cargo.toml index eed8dda2c1..adeb2e6ac0 100644 --- a/subxt/Cargo.toml +++ b/subxt/Cargo.toml @@ -28,7 +28,7 @@ jsonrpsee = { version = "0.12.0", features = ["async-client", "client-ws-transpo serde = { version = "1.0.124", features = ["derive"] } serde_json = "1.0.64" thiserror = "1.0.24" -trace = "0.1.6" +tracing = "0.1.34" parking_lot = "0.12.0" subxt-macro = { version = "0.21.0", path = "../macro" } From 8ff371ac9df385cc84585ab40eafa7725d3144fa Mon Sep 17 00:00:00 2001 From: ascjones Date: Thu, 12 May 2022 10:52:59 +0100 Subject: [PATCH 4/9] Log extrinsic hash and signature --- subxt/src/client.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/subxt/src/client.rs b/subxt/src/client.rs index 3072f674b4..26e0b88d88 100644 --- a/subxt/src/client.rs +++ b/subxt/src/client.rs @@ -250,6 +250,8 @@ where // Get a hash of the extrinsic (we'll need this later). let ext_hash = T::Hashing::hash_of(&extrinsic); + tracing::info!("xt hash: {}", hex::encode(ext_hash.encode())); + // Submit and watch for transaction progress. let sub = self.client.rpc().watch_extrinsic(extrinsic).await?; @@ -344,6 +346,8 @@ where } }; + tracing::info!("xt signature: {}", hex::encode(signature.encode())); + // 5. Encode extrinsic, now that we have the parts we need. This is compatible // with the Encode impl for UncheckedExtrinsic (protocol version 4). let extrinsic = { From df19af698d6b758a8b7db095324988aab70873a3 Mon Sep 17 00:00:00 2001 From: ascjones Date: Thu, 12 May 2022 11:03:26 +0100 Subject: [PATCH 5/9] Debug extrinsic params --- subxt/src/client.rs | 5 +++++ subxt/src/config.rs | 3 ++- subxt/src/extrinsic/params.rs | 12 +++++++----- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/subxt/src/client.rs b/subxt/src/client.rs index 26e0b88d88..83a62cae40 100644 --- a/subxt/src/client.rs +++ b/subxt/src/client.rs @@ -330,6 +330,11 @@ where other_params, ); + tracing::debug!( + "additional_and_extra_params: {:?}", + additional_and_extra_params + ); + // 4. Construct signature. This is compatible with the Encode impl // for SignedPayload (which is this payload of bytes that we'd like) // to sign. See: diff --git a/subxt/src/config.rs b/subxt/src/config.rs index d3ab09c42d..b8f3744118 100644 --- a/subxt/src/config.rs +++ b/subxt/src/config.rs @@ -34,7 +34,7 @@ use sp_runtime::traits::{ // Note: the 'static bound isn't strictly required, but currently deriving TypeInfo // automatically applies a 'static bound to all generic types (including this one), // and so until that is resolved, we'll keep the (easy to satisfy) constraint here. -pub trait Config: 'static { +pub trait Config: Debug + 'static { /// Account index (aka nonce) type. This stores the number of previous /// transactions associated with a sender account. type Index: Parameter @@ -95,6 +95,7 @@ impl Parameter for T where T: Codec + EncodeLike + Clone + Eq + Debug {} /// Default set of commonly used types by Substrate runtimes. // Note: We only use this at the type level, so it should be impossible to // create an instance of it. +#[derive(Debug)] pub enum DefaultConfig {} impl Config for DefaultConfig { diff --git a/subxt/src/extrinsic/params.rs b/subxt/src/extrinsic/params.rs index 981cbc6abb..0ad6928d37 100644 --- a/subxt/src/extrinsic/params.rs +++ b/subxt/src/extrinsic/params.rs @@ -18,6 +18,7 @@ use codec::{ Compact, Encode, }; +use core::fmt::Debug; use crate::{ Config, @@ -31,7 +32,7 @@ pub use sp_runtime::generic::Era; /// "additional" parameters that are signed and used in transactions. /// see [`BaseExtrinsicParams`] for an implementation that is compatible with /// a Polkadot node. -pub trait ExtrinsicParams { +pub trait ExtrinsicParams: Debug { /// These parameters can be provided to the constructor along with /// some default parameters that `subxt` understands, in order to /// help construct your [`ExtrinsicParams`] object. @@ -84,7 +85,8 @@ pub type PolkadotExtrinsicParamsBuilder = BaseExtrinsicParamsBuilder { +#[derive(Debug)] +pub struct BaseExtrinsicParams { era: Era, nonce: T::Index, tip: Tip, @@ -142,7 +144,7 @@ impl Default for BaseExtrinsicParamsBuilder { } } -impl ExtrinsicParams for BaseExtrinsicParams { +impl ExtrinsicParams for BaseExtrinsicParams { type OtherParams = BaseExtrinsicParamsBuilder; fn new( @@ -186,7 +188,7 @@ impl ExtrinsicParams for BaseExtrinsicParams } /// A tip payment. -#[derive(Copy, Clone, Default, Encode)] +#[derive(Copy, Clone, Debug, Default, Encode)] pub struct PlainTip { #[codec(compact)] tip: u128, @@ -206,7 +208,7 @@ impl From for PlainTip { } /// A tip payment made in the form of a specific asset. -#[derive(Copy, Clone, Default, Encode)] +#[derive(Copy, Clone, Debug, Default, Encode)] pub struct AssetTip { #[codec(compact)] tip: u128, From 7248ad484c6aecd14e1f785960b6ff994ca953b3 Mon Sep 17 00:00:00 2001 From: ascjones Date: Thu, 12 May 2022 11:08:35 +0100 Subject: [PATCH 6/9] Replace env_logger --- examples/Cargo.toml | 2 +- examples/examples/balance_transfer.rs | 2 +- examples/examples/balance_transfer_with_params.rs | 2 +- examples/examples/fetch_all_accounts.rs | 2 +- examples/examples/fetch_staking_details.rs | 2 +- examples/examples/metadata_compatibility.rs | 2 +- examples/examples/rpc_call.rs | 2 +- examples/examples/submit_and_watch.rs | 2 +- examples/examples/subscribe_all_events.rs | 2 +- examples/examples/subscribe_one_event.rs | 2 +- examples/examples/subscribe_some_events.rs | 2 +- integration-tests/Cargo.toml | 1 - subxt/Cargo.toml | 1 - 13 files changed, 11 insertions(+), 13 deletions(-) diff --git a/examples/Cargo.toml b/examples/Cargo.toml index 04220c7d35..88629af403 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -15,7 +15,7 @@ description = "Subxt example usage" subxt = { path = "../subxt" } tokio = { version = "1.8", features = ["rt-multi-thread", "macros", "time"] } sp-keyring = "6.0.0" -env_logger = "0.9.0" futures = "0.3.13" codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "full", "bit-vec"] } hex = "0.4.3" +tracing-subscriber = "0.3.11" diff --git a/examples/examples/balance_transfer.rs b/examples/examples/balance_transfer.rs index 21f64435ed..437d8c14c8 100644 --- a/examples/examples/balance_transfer.rs +++ b/examples/examples/balance_transfer.rs @@ -35,7 +35,7 @@ pub mod polkadot {} #[tokio::main] async fn main() -> Result<(), Box> { - env_logger::init(); + tracing_subscriber::fmt::init(); let signer = PairSigner::new(AccountKeyring::Alice.pair()); let dest = AccountKeyring::Bob.to_account_id().into(); diff --git a/examples/examples/balance_transfer_with_params.rs b/examples/examples/balance_transfer_with_params.rs index 9d00eacaa8..f59497a244 100644 --- a/examples/examples/balance_transfer_with_params.rs +++ b/examples/examples/balance_transfer_with_params.rs @@ -40,7 +40,7 @@ pub mod polkadot {} #[tokio::main] async fn main() -> Result<(), Box> { - env_logger::init(); + tracing_subscriber::fmt::init(); let signer = PairSigner::new(AccountKeyring::Alice.pair()); let dest = AccountKeyring::Bob.to_account_id().into(); diff --git a/examples/examples/fetch_all_accounts.rs b/examples/examples/fetch_all_accounts.rs index 32c0818f34..7cb134a2a6 100644 --- a/examples/examples/fetch_all_accounts.rs +++ b/examples/examples/fetch_all_accounts.rs @@ -33,7 +33,7 @@ pub mod polkadot {} #[tokio::main] async fn main() -> Result<(), Box> { - env_logger::init(); + tracing_subscriber::fmt::init(); let api = ClientBuilder::new() .build() diff --git a/examples/examples/fetch_staking_details.rs b/examples/examples/fetch_staking_details.rs index 180f210397..394c2ead85 100644 --- a/examples/examples/fetch_staking_details.rs +++ b/examples/examples/fetch_staking_details.rs @@ -39,7 +39,7 @@ pub mod polkadot {} #[tokio::main] async fn main() -> Result<(), Box> { - env_logger::init(); + tracing_subscriber::fmt::init(); let api = ClientBuilder::new() .build() diff --git a/examples/examples/metadata_compatibility.rs b/examples/examples/metadata_compatibility.rs index a660bb9d14..6a034cd930 100644 --- a/examples/examples/metadata_compatibility.rs +++ b/examples/examples/metadata_compatibility.rs @@ -33,7 +33,7 @@ pub mod polkadot {} #[tokio::main] async fn main() -> Result<(), Box> { - env_logger::init(); + tracing_subscriber::fmt::init(); let api = ClientBuilder::new() .build() diff --git a/examples/examples/rpc_call.rs b/examples/examples/rpc_call.rs index 414a1d2f25..26efc4ed00 100644 --- a/examples/examples/rpc_call.rs +++ b/examples/examples/rpc_call.rs @@ -33,7 +33,7 @@ pub mod polkadot {} #[tokio::main] async fn main() -> Result<(), Box> { - env_logger::init(); + tracing_subscriber::fmt::init(); let api = ClientBuilder::new() .set_url("wss://rpc.polkadot.io:443") diff --git a/examples/examples/submit_and_watch.rs b/examples/examples/submit_and_watch.rs index c41d7541ef..42da262269 100644 --- a/examples/examples/submit_and_watch.rs +++ b/examples/examples/submit_and_watch.rs @@ -36,7 +36,7 @@ pub mod polkadot {} #[tokio::main] async fn main() -> Result<(), Box> { - env_logger::init(); + tracing_subscriber::fmt::init(); simple_transfer().await?; simple_transfer_separate_events().await?; diff --git a/examples/examples/subscribe_all_events.rs b/examples/examples/subscribe_all_events.rs index 304cf4bd59..a9a651d6d6 100644 --- a/examples/examples/subscribe_all_events.rs +++ b/examples/examples/subscribe_all_events.rs @@ -39,7 +39,7 @@ pub mod polkadot {} /// pluck out the events that we care about. #[tokio::main] async fn main() -> Result<(), Box> { - env_logger::init(); + tracing_subscriber::fmt::init(); let api = ClientBuilder::new() .build() diff --git a/examples/examples/subscribe_one_event.rs b/examples/examples/subscribe_one_event.rs index 1d09071a25..2ad6b6be22 100644 --- a/examples/examples/subscribe_one_event.rs +++ b/examples/examples/subscribe_one_event.rs @@ -39,7 +39,7 @@ pub mod polkadot {} /// pluck out the events that we care about. #[tokio::main] async fn main() -> Result<(), Box> { - env_logger::init(); + tracing_subscriber::fmt::init(); // Subscribe to any events that occur: let api = ClientBuilder::new() diff --git a/examples/examples/subscribe_some_events.rs b/examples/examples/subscribe_some_events.rs index 2e253ad16c..6684af3ddf 100644 --- a/examples/examples/subscribe_some_events.rs +++ b/examples/examples/subscribe_some_events.rs @@ -39,7 +39,7 @@ pub mod polkadot {} /// pluck out the events that we care about. #[tokio::main] async fn main() -> Result<(), Box> { - env_logger::init(); + tracing_subscriber::fmt::init(); // Subscribe to any events that occur: let api = ClientBuilder::new() diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index 2a15ac50a6..519a96e513 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -18,7 +18,6 @@ default = ["subxt/integration-tests"] assert_matches = "1.5.0" async-trait = "0.1.49" codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "full", "bit-vec"] } -env_logger = "0.9.0" frame-metadata = "15.0.0" futures = "0.3.13" hex = "0.4.3" diff --git a/subxt/Cargo.toml b/subxt/Cargo.toml index adeb2e6ac0..ec12b41e79 100644 --- a/subxt/Cargo.toml +++ b/subxt/Cargo.toml @@ -44,7 +44,6 @@ derivative = "2.2.0" sp-arithmetic = { version = "5.0.0", default-features = false } assert_matches = "1.5.0" tokio = { version = "1.8", features = ["macros", "time"] } -env_logger = "0.9.0" tempdir = "0.3.7" wabt = "0.10.0" which = "4.0.2" From 5c04a36d173e8521de0182806ff92a80129e86bd Mon Sep 17 00:00:00 2001 From: ascjones Date: Thu, 12 May 2022 11:10:20 +0100 Subject: [PATCH 7/9] Replace more env_logger init --- integration-tests/src/events/mod.rs | 8 ++++---- integration-tests/src/frame/balances.rs | 4 ++-- integration-tests/src/frame/contracts.rs | 2 +- integration-tests/src/utils/context.rs | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/integration-tests/src/events/mod.rs b/integration-tests/src/events/mod.rs index 937a4faf91..871571ea63 100644 --- a/integration-tests/src/events/mod.rs +++ b/integration-tests/src/events/mod.rs @@ -28,7 +28,7 @@ use sp_keyring::AccountKeyring; // Check that we can subscribe to non-finalized block events. #[tokio::test] async fn non_finalized_block_subscription() -> Result<(), subxt::BasicError> { - env_logger::try_init().ok(); + tracing_subscriber::fmt::try_init().ok(); let ctx = test_context().await; let mut event_sub = ctx.api.events().subscribe().await?; @@ -46,7 +46,7 @@ async fn non_finalized_block_subscription() -> Result<(), subxt::BasicError> { // Check that we can subscribe to finalized block events. #[tokio::test] async fn finalized_block_subscription() -> Result<(), subxt::BasicError> { - env_logger::try_init().ok(); + tracing_subscriber::fmt::try_init().ok(); let ctx = test_context().await; let mut event_sub = ctx.api.events().subscribe_finalized().await?; @@ -66,7 +66,7 @@ async fn finalized_block_subscription() -> Result<(), subxt::BasicError> { // a few blocks. #[tokio::test] async fn subscription_produces_events_each_block() -> Result<(), subxt::BasicError> { - env_logger::try_init().ok(); + tracing_subscriber::fmt::try_init().ok(); let ctx = test_context().await; let mut event_sub = ctx.api.events().subscribe().await?; @@ -95,7 +95,7 @@ async fn subscription_produces_events_each_block() -> Result<(), subxt::BasicErr // it's Stream impl, and ultimately see the event we expect. #[tokio::test] async fn balance_transfer_subscription() -> Result<(), subxt::BasicError> { - env_logger::try_init().ok(); + tracing_subscriber::fmt::try_init().ok(); let ctx = test_context().await; // Subscribe to balance transfer events, ignoring all else. diff --git a/integration-tests/src/frame/balances.rs b/integration-tests/src/frame/balances.rs index b977eee427..5c33492539 100644 --- a/integration-tests/src/frame/balances.rs +++ b/integration-tests/src/frame/balances.rs @@ -189,7 +189,7 @@ async fn storage_balance_lock() -> Result<(), subxt::Error> { #[tokio::test] async fn transfer_error() { - env_logger::try_init().ok(); + tracing_subscriber::fmt::try_init().ok(); let alice = pair_signer(AccountKeyring::Alice.pair()); let alice_addr = alice.account_id().clone().into(); let hans = pair_signer(Pair::generate().0); @@ -230,7 +230,7 @@ async fn transfer_error() { #[tokio::test] async fn transfer_implicit_subscription() { - env_logger::try_init().ok(); + tracing_subscriber::fmt::try_init().ok(); let alice = pair_signer(AccountKeyring::Alice.pair()); let bob = AccountKeyring::Bob.to_account_id(); let bob_addr = bob.clone().into(); diff --git a/integration-tests/src/frame/contracts.rs b/integration-tests/src/frame/contracts.rs index 8849180c3d..8be1727862 100644 --- a/integration-tests/src/frame/contracts.rs +++ b/integration-tests/src/frame/contracts.rs @@ -52,7 +52,7 @@ type AccountId = ::AccountId; impl ContractsTestContext { async fn init() -> Self { - let _ = tracing_subscriber::fmt::try_init(); + tracing_subscriber::fmt::try_init().ok(); let cxt = test_context().await; let signer = PairSigner::new(AccountKeyring::Alice.pair()); diff --git a/integration-tests/src/utils/context.rs b/integration-tests/src/utils/context.rs index b1e85d102b..a612fa07b9 100644 --- a/integration-tests/src/utils/context.rs +++ b/integration-tests/src/utils/context.rs @@ -67,7 +67,7 @@ impl TestContext { } pub async fn test_context() -> TestContext { - env_logger::try_init().ok(); + tracing_subscriber::fmt::try_init().ok(); let node_proc = test_node_process_with(AccountKeyring::Alice).await; let api = node_proc.client().clone().to_runtime_api(); TestContext { node_proc, api } From 0353a7bb1ac85ecc5c9219249362df977371533e Mon Sep 17 00:00:00 2001 From: ascjones Date: Thu, 12 May 2022 11:26:14 +0100 Subject: [PATCH 8/9] Replace new logs with tracing --- subxt/src/updates.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/subxt/src/updates.rs b/subxt/src/updates.rs index dd7638d5ea..e304d4f4f7 100644 --- a/subxt/src/updates.rs +++ b/subxt/src/updates.rs @@ -73,7 +73,7 @@ impl UpdateClient { // or during updates. let runtime_version = self.runtime_version.read(); if runtime_version.spec_version == update_runtime_version.spec_version { - log::debug!( + tracing::debug!( "Runtime update not performed for spec_version={}, client has spec_version={}", update_runtime_version.spec_version, runtime_version.spec_version ); @@ -85,7 +85,7 @@ impl UpdateClient { { let mut runtime_version = self.runtime_version.write(); // Update both the `RuntimeVersion` and `Metadata` of the client. - log::info!( + tracing::info!( "Performing runtime update from {} to {}", runtime_version.spec_version, update_runtime_version.spec_version, @@ -95,10 +95,10 @@ impl UpdateClient { // Fetch the new metadata of the runtime node. let update_metadata = self.rpc.metadata().await?; - log::debug!("Performing metadata update"); + tracing::debug!("Performing metadata update"); let mut metadata = self.metadata.write(); *metadata = update_metadata; - log::debug!("Runtime update completed"); + tracing::debug!("Runtime update completed"); } Ok(()) From 955944acb66fdb3917f51ca346ca45119bbd8858 Mon Sep 17 00:00:00 2001 From: ascjones Date: Thu, 12 May 2022 11:35:02 +0100 Subject: [PATCH 9/9] Fix final env_logger --- examples/examples/subscribe_runtime_updates.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/examples/subscribe_runtime_updates.rs b/examples/examples/subscribe_runtime_updates.rs index 2b97397037..a8d8c9736c 100644 --- a/examples/examples/subscribe_runtime_updates.rs +++ b/examples/examples/subscribe_runtime_updates.rs @@ -36,7 +36,7 @@ pub mod polkadot {} #[tokio::main] async fn main() -> Result<(), Box> { - env_logger::init(); + tracing_subscriber::fmt::init(); let api = ClientBuilder::new() .build()