diff --git a/Cargo.lock b/Cargo.lock index 81c88ef5d3326..ddd357ab35cc2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -24882,9 +24882,9 @@ checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" [[package]] name = "test-log" -version = "0.2.16" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dffced63c2b5c7be278154d76b479f9f9920ed34e7574201407f0b14e2bbb93" +checksum = "1e33b98a582ea0be1168eba097538ee8dd4bbe0f2b01b22ac92ea30054e5be7b" dependencies = [ "env_logger 0.11.3", "test-log-macros", @@ -24893,9 +24893,9 @@ dependencies = [ [[package]] name = "test-log-macros" -version = "0.2.16" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5999e24eaa32083191ba4e425deb75cdf25efefabe5aaccb7446dd0d4122a3f5" +checksum = "451b374529930d7601b1eef8d32bc79ae870b6079b069401709c2a8bf9e75f36" dependencies = [ "proc-macro2 1.0.95", "quote 1.0.40", @@ -27324,7 +27324,6 @@ dependencies = [ "frame-support", "frame-system", "impl-trait-for-tuples", - "log", "pallet-balances", "pallet-message-queue", "pallet-timestamp", @@ -27342,6 +27341,7 @@ dependencies = [ "sp-tracing 16.0.0", "staging-xcm", "staging-xcm-executor", + "tracing", "xcm-simulator", ] diff --git a/cumulus/xcm/xcm-emulator/Cargo.toml b/cumulus/xcm/xcm-emulator/Cargo.toml index a57df58b03ec6..94da0f9b4b1e2 100644 --- a/cumulus/xcm/xcm-emulator/Cargo.toml +++ b/cumulus/xcm/xcm-emulator/Cargo.toml @@ -15,8 +15,8 @@ workspace = true array-bytes = { workspace = true } codec = { workspace = true, default-features = true } impl-trait-for-tuples = { workspace = true } -log = { workspace = true } paste = { workspace = true, default-features = true } +tracing = { workspace = true } # Substrate frame-support = { workspace = true, default-features = true } diff --git a/cumulus/xcm/xcm-emulator/src/lib.rs b/cumulus/xcm/xcm-emulator/src/lib.rs index a4d40fa87acee..6ab5366b04035 100644 --- a/cumulus/xcm/xcm-emulator/src/lib.rs +++ b/cumulus/xcm/xcm-emulator/src/lib.rs @@ -18,7 +18,6 @@ extern crate alloc; pub use array_bytes; pub use codec::{Decode, Encode, EncodeLike, MaxEncodedLen}; -pub use log; pub use paste; pub use std::{ any::type_name, @@ -29,6 +28,7 @@ pub use std::{ ops::Deref, sync::{Arc, LazyLock, Mutex}, }; +pub use tracing; // Substrate pub use alloc::collections::vec_deque::VecDeque; @@ -552,7 +552,7 @@ macro_rules! __impl_test_ext_for_relay_chain { // Execute let r = $local_ext.with(|v| { - $crate::log::info!(target: "xcm::emulator::execute_with", "Executing as {}", stringify!($name)); + $crate::tracing::info!(target: "xcm::emulator::execute_with", "Executing as {}", stringify!($name)); v.borrow_mut().execute_with(execute) }); @@ -578,7 +578,7 @@ macro_rules! __impl_test_ext_for_relay_chain { // log events Self::events().iter().for_each(|event| { - $crate::log::info!(target: concat!("events::", stringify!($name)), "{:?}", event); + $crate::tracing::info!(target: concat!("events::", stringify!($name)), ?event, "Event emitted"); }); // clean events @@ -904,7 +904,7 @@ macro_rules! __impl_test_ext_for_parachain { // Execute let r = $local_ext.with(|v| { - $crate::log::info!(target: "xcm::emulator::execute_with", "Executing as {}", stringify!($name)); + $crate::tracing::info!(target: "xcm::emulator::execute_with", "Executing as {}", stringify!($name)); v.borrow_mut().execute_with(execute) }); @@ -952,7 +952,7 @@ macro_rules! __impl_test_ext_for_parachain { // log events ::events().iter().for_each(|event| { - $crate::log::info!(target: concat!("events::", stringify!($name)), "{:?}", event); + $crate::tracing::info!(target: concat!("events::", stringify!($name)), ?event, "Event emitted"); }); // clean events @@ -1107,7 +1107,7 @@ macro_rules! decl_test_networks { let messages = msgs.clone().iter().map(|(block, message)| { (*block, $crate::array_bytes::bytes2hex("0x", message)) }).collect::>(); - $crate::log::info!(target: concat!("xcm::dmp::", stringify!($name)) , "Downward messages processed by para_id {:?}: {:?}", &to_para_id, messages); + $crate::tracing::info!(target: concat!("xcm::dmp::", stringify!($name)), ?to_para_id, ?messages, "Downward messages processed"); $crate::DMP_DONE.with(|b| b.borrow_mut().get_mut(Self::name()).unwrap().push_back((to_para_id, block, msg))); } } @@ -1133,7 +1133,7 @@ macro_rules! decl_test_networks { let messages = messages.clone().iter().map(|(para_id, relay_block_number, message)| { (*para_id, *relay_block_number, $crate::array_bytes::bytes2hex("0x", message)) }).collect::>(); - $crate::log::info!(target: concat!("xcm::hrmp::", stringify!($name)), "Horizontal messages processed by para_id {:?}: {:?}", &to_para_id, &messages); + $crate::tracing::info!(target: concat!("xcm::hrmp::", stringify!($name)), ?to_para_id, ?messages, "Horizontal messages processed"); } )* } @@ -1153,7 +1153,7 @@ macro_rules! decl_test_networks { ); }); let message = $crate::array_bytes::bytes2hex("0x", msg.clone()); - $crate::log::info!(target: concat!("xcm::ump::", stringify!($name)) , "Upward message processed from para_id {:?}: {:?}", &from_para_id, &message); + $crate::tracing::info!(target: concat!("xcm::ump::", stringify!($name)), ?from_para_id, ?message, "Upward message processed"); } } @@ -1173,7 +1173,7 @@ macro_rules! decl_test_networks { <::Source as TestExt>::ext_wrapper(|| { <::Handler as BridgeMessageHandler>::notify_source_message_delivery(msg.lane_id.clone()); }); - $crate::log::info!(target: concat!("bridge::", stringify!($name)) , "Bridged message processed {:?}", msg); + $crate::tracing::info!(target: concat!("bridge::", stringify!($name)), ?msg, "Bridged message processed"); } } } @@ -1394,7 +1394,7 @@ macro_rules! assert_expected_events { if !messages.is_empty() { // Log all events (since they won't be logged after the panic). <$chain as $crate::Chain>::events().iter().for_each(|event| { - $crate::log::info!(target: concat!("events::", stringify!($chain)), "{:?}", event); + $crate::tracing::info!(target: concat!("events::", stringify!($chain)), ?event, "Event emitted"); }); panic!("{}", messages.concat()) } diff --git a/prdoc/pr_9409.prdoc b/prdoc/pr_9409.prdoc new file mode 100644 index 0000000000000..2b85a5306cb95 --- /dev/null +++ b/prdoc/pr_9409.prdoc @@ -0,0 +1,8 @@ +title: Replace `log` with `tracing` on `xcm-emulator` +doc: +- audience: Runtime Dev + description: This PR replaces `log` with `tracing` instrumentation on `xcm-emulator` + by providing structured logging. +crates: +- name: xcm-emulator + bump: minor