Skip to content

Conversation

raymondkfcheung
Copy link
Contributor

@raymondkfcheung raymondkfcheung commented Jul 31, 2025

This PR replaces log with tracing instrumentation on xcm-emulator by providing structured logging.

Continues #8732

@raymondkfcheung raymondkfcheung self-assigned this Jul 31, 2025
@raymondkfcheung raymondkfcheung added the T6-XCM This PR/Issue is related to XCM. label Jul 31, 2025
@raymondkfcheung raymondkfcheung requested a review from a team July 31, 2025 15:24
// 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

(*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

(*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

});
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

<<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

// 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

// 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

@raymondkfcheung raymondkfcheung added the C2-good-first-issue A task for a first time contributor to become familiar with the Polkadot-SDK. label Aug 1, 2025
@raymondkfcheung raymondkfcheung added this pull request to the merge queue Aug 4, 2025
Merged via the queue into master with commit c16e9e2 Aug 4, 2025
319 of 324 checks passed
@raymondkfcheung raymondkfcheung deleted the ray-xcm-tracing branch August 4, 2025 13:41
alvicsam pushed a commit that referenced this pull request Oct 17, 2025
This PR replaces `log` with `tracing` instrumentation on `xcm-emulator`
by providing structured logging.

Continues #8732
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C2-good-first-issue A task for a first time contributor to become familiar with the Polkadot-SDK. T6-XCM This PR/Issue is related to XCM.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants