Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cumulus/xcm/xcm-emulator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
20 changes: 10 additions & 10 deletions cumulus/xcm/xcm-emulator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -29,6 +28,7 @@ pub use std::{
ops::Deref,
sync::{Arc, LazyLock, Mutex},
};
pub use tracing;

// Substrate
pub use alloc::collections::vec_deque::VecDeque;
Expand Down Expand Up @@ -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)
});

Expand All @@ -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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$crate::tracing::info!(target: concat!("events::", stringify!($name)), "{:?}", event);
$crate::tracing::info!(target: concat!("events::", stringify!($name)), ?event, "Event processed");

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed

});

// clean events
Expand Down Expand Up @@ -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)
});

Expand Down Expand Up @@ -952,7 +952,7 @@ macro_rules! __impl_test_ext_for_parachain {

// log events
<Self as $crate::Chain>::events().iter().for_each(|event| {
$crate::log::info!(target: concat!("events::", stringify!($name)), "{:?}", event);
$crate::tracing::info!(target: concat!("events::", stringify!($name)), "{:?}", event);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$crate::tracing::info!(target: concat!("events::", stringify!($name)), "{:?}", event);
$crate::tracing::info!(target: concat!("events::", stringify!($name)), ?event, "Event processed");

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed

});

// clean events
Expand Down Expand Up @@ -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::<Vec<_>>();
$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)) , "Downward messages processed by para_id {:?}: {:?}", &to_para_id, messages);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$crate::tracing::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");

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed

$crate::DMP_DONE.with(|b| b.borrow_mut().get_mut(Self::name()).unwrap().push_back((to_para_id, block, msg)));
}
}
Expand All @@ -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::<Vec<_>>();
$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)), "Horizontal messages processed by para_id {:?}: {:?}", &to_para_id, &messages);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$crate::tracing::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");

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed

}
)*
}
Expand All @@ -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)) , "Upward message processed from para_id {:?}: {:?}", &from_para_id, &message);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$crate::tracing::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");

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed

}
}

Expand All @@ -1173,7 +1173,7 @@ macro_rules! decl_test_networks {
<<Self::Bridge as Bridge>::Source as TestExt>::ext_wrapper(|| {
<<Self::Bridge as Bridge>::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)) , "Bridged message processed {:?}", msg);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$crate::tracing::info!(target: concat!("bridge::", stringify!($name)) , "Bridged message processed {:?}", msg);
$crate::tracing::info!(target: concat!("bridge::", stringify!($name)) , ?msg, "Bridged message processed");

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed

}
}
}
Expand Down Expand Up @@ -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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$crate::tracing::info!(target: concat!("events::", stringify!($chain)), "{:?}", event);
$crate::tracing::info!(target: concat!("events::", stringify!($chain)), event, "Event processed");

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed

});
panic!("{}", messages.concat())
}
Expand Down
8 changes: 8 additions & 0 deletions prdoc/pr_9409.prdoc
Original file line number Diff line number Diff line change
@@ -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
Loading