Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

level-monitor: Use prroper log target #2493

Merged
merged 2 commits into from
Apr 28, 2023
Merged
Changes from all commits
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
33 changes: 22 additions & 11 deletions client/consensus/common/src/level_monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ use std::{
sync::Arc,
};

const LOG_TARGET: &'static str = "level-monitor";

/// Value good enough to be used with parachains using the current backend implementation
/// that ships with Substrate. This value may change in the future.
pub const MAX_LEAVES_PER_LEVEL_SENSIBLE_DEFAULT: usize = 32;
Expand Down Expand Up @@ -100,9 +102,10 @@ where
let info = self.backend.blockchain().info();

log::debug!(
target: "parachain",
target: LOG_TARGET,
"Restoring chain level monitor from last finalized block: {} {}",
info.finalized_number, info.finalized_hash
info.finalized_number,
info.finalized_hash
);

self.lowest_level = info.finalized_number;
Expand All @@ -124,7 +127,11 @@ where
}
}

log::debug!(target: "parachain", "Restored chain level monitor up to height {}", self.import_counter);
log::debug!(
target: LOG_TARGET,
"Restored chain level monitor up to height {}",
self.import_counter
);
}

/// Check and enforce the limit bound at the given height.
Expand Down Expand Up @@ -161,7 +168,7 @@ where
let remove_count = level_len - self.level_limit + 1;

log::debug!(
target: "parachain",
target: LOG_TARGET,
"Detected leaves overflow at height {number}, removing {remove_count} obsolete blocks",
);

Expand Down Expand Up @@ -224,9 +231,11 @@ where
}),
Err(err) => {
log::warn!(
target: "parachain",
target: LOG_TARGET,
"(Lookup) Unable getting route from {:?} to {:?}: {}",
blk_hash, leaf_hash, err,
blk_hash,
leaf_hash,
err,
);
None
},
Expand All @@ -243,7 +252,7 @@ where
None => {
// This should never happen
log::error!(
target: "parachain",
target: LOG_TARGET,
"Unable getting route to any leaf from {:?} (this is a bug)",
blk_hash,
);
Expand Down Expand Up @@ -294,9 +303,9 @@ where
invalidated_leaves: &mut HashSet<usize>,
) {
let mut remove_leaf = |number, hash| {
log::debug!(target: "parachain", "Removing block (@{}) {:?}", number, hash);
log::debug!(target: LOG_TARGET, "Removing block (@{}) {:?}", number, hash);
if let Err(err) = self.backend.remove_leaf_block(hash) {
log::debug!(target: "parachain", "Remove not possible for {}: {}", hash, err);
log::debug!(target: LOG_TARGET, "Remove not possible for {}: {}", hash, err);
return false
}
self.levels.get_mut(&number).map(|level| level.remove(&hash));
Expand Down Expand Up @@ -337,9 +346,11 @@ where
},
Err(err) => {
log::warn!(
target: "parachain",
target: LOG_TARGET,
"(Removal) unable getting route from {:?} to {:?}: {}",
target_hash, leaf_hash, err,
target_hash,
leaf_hash,
err,
);
},
_ => (),
Expand Down