Skip to content

Commit a3a0e03

Browse files
committed
feat: adopt tracing for structured logging (#123)
Replace all uses of the log crate with the tracing ecosystem across: - pallets/validator-set - pallets/relayer-set - runtime/ - runtimes/bulletin-polkadot This aligns with upstream Polkadot SDK initiatives for improved observability and debuggability.
1 parent 93f011b commit a3a0e03

File tree

12 files changed

+34
-34
lines changed

12 files changed

+34
-34
lines changed

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pallets/relayer-set/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ targets = ["x86_64-unknown-linux-gnu"]
1212

1313
[dependencies]
1414
codec = { workspace = true }
15-
log = { workspace = true, default-features = true }
15+
tracing = { workspace = true, default-features = true }
1616
scale-info = { features = ["derive"], workspace = true }
1717

1818
polkadot-sdk-frame = { workspace = true, default-features = false, features = [
@@ -26,7 +26,7 @@ runtime-benchmarks = [
2626
]
2727
std = [
2828
"codec/std",
29-
"log/std",
29+
"tracing/std",
3030
"polkadot-sdk-frame/std",
3131
"scale-info/std",
3232
]

pallets/relayer-set/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ impl<T: Config> Pallet<T> {
156156

157157
// Decrement who's provider reference count
158158
if let Err(err) = frame_system::Pallet::<T>::dec_providers(who) {
159-
log::warn!(
159+
tracing::warn!(
160160
target: LOG_TARGET,
161161
"Failed to decrement provider reference count for relayer {who:?}, \
162162
leaking reference: {err:?}"
@@ -185,7 +185,7 @@ impl<T: Config> Pallet<T> {
185185
Some(relayer) =>
186186
relayer.min_bridge_tx_block = frame_system::Pallet::<T>::block_number()
187187
.saturating_add(T::BridgeTxFailCooldownBlocks::get()),
188-
None => log::warn!(
188+
None => tracing::warn!(
189189
target: LOG_TARGET,
190190
"Could not find signer {who:?} of failed bridge transaction in relayer set"
191191
),

pallets/validator-set/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ license = 'Apache-2.0'
88

99
[dependencies]
1010
codec = { workspace = true, features = ["derive"] }
11-
log = { workspace = true, default-features = true }
11+
tracing = { workspace = true, default-features = true }
1212
scale-info = { features = ["derive"], workspace = true }
1313

1414
polkadot-sdk-frame = { workspace = true, default-features = false, features = [
@@ -32,7 +32,7 @@ runtime-benchmarks = [
3232
"sp-staking/runtime-benchmarks",
3333
]
3434
std = [
35-
"log/std",
35+
"tracing/std",
3636
"pallets-common/std",
3737
"sp-staking/std",
3838
'codec/std',

pallets/validator-set/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,13 +238,13 @@ impl<T: Config> Pallet<T> {
238238
if let Err(err) =
239239
pallet_session::Pallet::<T>::purge_keys(RawOrigin::Signed(who.clone()).into())
240240
{
241-
log::trace!(
241+
tracing::trace!(
242242
target: LOG_TARGET,
243243
"Failed to purge session keys for validator {who:?}: {err:?}"
244244
);
245245
}
246246
if let Err(err) = frame_system::Pallet::<T>::dec_providers(who) {
247-
log::warn!(
247+
tracing::warn!(
248248
target: LOG_TARGET,
249249
"Failed to decrement provider reference count for validator {who:?}, \
250250
leaking reference: {err:?}"

runtime/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ targets = ["x86_64-unknown-linux-gnu"]
1313

1414
[dependencies]
1515
codec = { workspace = true, features = ["derive"] }
16-
log = { workspace = true }
16+
tracing = { workspace = true }
1717
scale-info = { features = ["derive"], workspace = true }
1818
serde_json = { features = ["alloc"], workspace = true }
1919
frame-executive = { workspace = true }
@@ -104,7 +104,7 @@ static_assertions = { workspace = true }
104104
default = ["std"]
105105
std = [
106106
"codec/std",
107-
"log/std",
107+
"tracing/std",
108108
"scale-info/std",
109109
"serde_json/std",
110110

runtime/src/bridge_config.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ impl<BlobDispatcher: DispatchBlob, Weights: pallet_bridge_messages::WeightInfoEx
153153
let payload = match message.data.payload {
154154
Ok(payload) => payload,
155155
Err(e) => {
156-
log::error!(
156+
tracing::error!(
157157
target: LOG_TARGET_BRIDGE_DISPATCH,
158158
"dispatch - payload error: {e:?} for lane_id: {:?} and message_nonce: {:?}",
159159
message.key.lane_id,
@@ -167,7 +167,7 @@ impl<BlobDispatcher: DispatchBlob, Weights: pallet_bridge_messages::WeightInfoEx
167167
};
168168
let dispatch_level_result = match BlobDispatcher::dispatch_blob(payload) {
169169
Ok(_) => {
170-
log::debug!(
170+
tracing::debug!(
171171
target: LOG_TARGET_BRIDGE_DISPATCH,
172172
"dispatch - `DispatchBlob::dispatch_blob` was ok for lane_id: {:?} and message_nonce: {:?}",
173173
message.key.lane_id,
@@ -176,7 +176,7 @@ impl<BlobDispatcher: DispatchBlob, Weights: pallet_bridge_messages::WeightInfoEx
176176
XcmBlobMessageDispatchResult::Dispatched
177177
},
178178
Err(e) => {
179-
log::error!(
179+
tracing::error!(
180180
target: LOG_TARGET_BRIDGE_DISPATCH,
181181
"dispatch - `DispatchBlob::dispatch_blob` failed with error: {e:?} for lane_id: {:?} and message_nonce: {:?}",
182182
message.key.lane_id,
@@ -279,7 +279,7 @@ where
279279
XCM_LANE, &blob,
280280
)
281281
.map_err(|e| {
282-
log::error!(
282+
tracing::error!(
283283
target: LOG_TARGET_BRIDGE_DISPATCH,
284284
"haul_blob result - error: {e:?} on lane: {XCM_LANE:?}",
285285
);
@@ -288,7 +288,7 @@ where
288288
let artifacts = pallet_bridge_messages::Pallet::<Runtime, MessagesInstance>::send_message(
289289
send_message_args,
290290
);
291-
log::info!(
291+
tracing::info!(
292292
target: LOG_TARGET_BRIDGE_DISPATCH,
293293
"haul_blob result - ok: {:?} on lane: {:?}. Enqueued messages: {}",
294294
artifacts.nonce,

runtime/src/xcm_config.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ impl ConvertOrigin<RuntimeOrigin> for KawabungaParachainAsRoot {
9999
kind: OriginKind,
100100
) -> Result<RuntimeOrigin, Location> {
101101
let origin = origin.into();
102-
log::trace!(
102+
tracing::trace!(
103103
target: "xcm::origin_conversion",
104104
"KawabungaParachainAsRoot origin: {origin:?}, kind: {kind:?}",
105105
);
@@ -148,7 +148,7 @@ impl<RuntimeCall: Decode, AllowedOrigin: Contains<Location>> ShouldExecute
148148
max_weight: Weight,
149149
_properties: &mut xcm_executor::traits::Properties,
150150
) -> Result<(), ProcessMessageError> {
151-
log::trace!(
151+
tracing::trace!(
152152
target: "xcm::barriers",
153153
"AllowUnpaidTransactsFrom origin: {origin:?}, instructions: {instructions:?}, max_weight: {max_weight:?}, properties:
154154
{_properties:?}",
@@ -247,7 +247,7 @@ impl DispatchBlob for ImmediateXcmDispatcher {
247247
let message: Xcm<RuntimeCall> =
248248
message.try_into().map_err(|_| DispatchBlobError::UnsupportedXcmVersion)?;
249249

250-
log::trace!(
250+
tracing::trace!(
251251
target: "runtime::xcm",
252252
"Going to dispatch XCM message from {:?}: {:?}",
253253
KawabungaLocation::get(),
@@ -270,7 +270,7 @@ impl DispatchBlob for ImmediateXcmDispatcher {
270270
)
271271
.ensure_complete()
272272
.map_err(|e| {
273-
log::trace!(
273+
tracing::trace!(
274274
target: "runtime::xcm",
275275
"XCM message from {:?} was dispatched with an error: {:?}",
276276
KawabungaLocation::get(),

runtimes/bulletin-polkadot/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ targets = ["x86_64-unknown-linux-gnu"]
1313

1414
[dependencies]
1515
codec = { workspace = true, features = ["derive"] }
16-
log = { workspace = true }
16+
tracing = { workspace = true }
1717
scale-info = { features = ["derive"], workspace = true }
1818
serde_json = { features = ["alloc"], workspace = true }
1919
frame-executive = { workspace = true }
@@ -105,7 +105,7 @@ sp-tracing = { workspace = true }
105105
default = ["std"]
106106
std = [
107107
"codec/std",
108-
"log/std",
108+
"tracing/std",
109109
"scale-info/std",
110110
"serde_json/std",
111111

runtimes/bulletin-polkadot/src/polkadot_bridge_config.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ impl<BlobDispatcher: DispatchBlob, Weights: pallet_bridge_messages::WeightInfoEx
262262
let payload = match message.data.payload {
263263
Ok(payload) => payload,
264264
Err(e) => {
265-
log::error!(
265+
tracing::error!(
266266
target: LOG_TARGET_BRIDGE_DISPATCH,
267267
"dispatch - payload error: {e:?} for lane_id: {:?} and message_nonce: {:?}",
268268
message.key.lane_id,
@@ -276,7 +276,7 @@ impl<BlobDispatcher: DispatchBlob, Weights: pallet_bridge_messages::WeightInfoEx
276276
};
277277
let dispatch_level_result = match BlobDispatcher::dispatch_blob(payload) {
278278
Ok(_) => {
279-
log::debug!(
279+
tracing::debug!(
280280
target: LOG_TARGET_BRIDGE_DISPATCH,
281281
"dispatch - `DispatchBlob::dispatch_blob` was ok for lane_id: {:?} and message_nonce: {:?}",
282282
message.key.lane_id,
@@ -285,7 +285,7 @@ impl<BlobDispatcher: DispatchBlob, Weights: pallet_bridge_messages::WeightInfoEx
285285
XcmBlobMessageDispatchResult::Dispatched
286286
},
287287
Err(e) => {
288-
log::error!(
288+
tracing::error!(
289289
target: LOG_TARGET_BRIDGE_DISPATCH,
290290
"dispatch - `DispatchBlob::dispatch_blob` failed with error: {e:?} for lane_id: {:?} and message_nonce: {:?}",
291291
message.key.lane_id,
@@ -401,7 +401,7 @@ where
401401
XCM_LANE, &blob,
402402
)
403403
.map_err(|e| {
404-
log::error!(
404+
tracing::error!(
405405
target: LOG_TARGET_BRIDGE_DISPATCH,
406406
"haul_blob result - error: {e:?} on lane: {XCM_LANE:?}",
407407
);
@@ -410,7 +410,7 @@ where
410410
let artifacts = pallet_bridge_messages::Pallet::<Runtime, MessagesInstance>::send_message(
411411
send_message_args,
412412
);
413-
log::info!(
413+
tracing::info!(
414414
target: LOG_TARGET_BRIDGE_DISPATCH,
415415
"haul_blob result - ok: {:?} on lane: {:?}. Enqueued messages: {}",
416416
artifacts.nonce,

0 commit comments

Comments
 (0)