level-monitor: Use prroper log target (#2493)

* level-monitor: Use prroper log target

* ".git/.scripts/commands/fmt/fmt.sh"

---------

Co-authored-by: command-bot <>
This commit is contained in:
Bastian Köcher
2023-04-28 09:45:44 +02:00
committed by GitHub
parent b441d05dac
commit cefabfb802
@@ -22,6 +22,8 @@ use std::{
sync::Arc, sync::Arc,
}; };
const LOG_TARGET: &'static str = "level-monitor";
/// Value good enough to be used with parachains using the current backend implementation /// Value good enough to be used with parachains using the current backend implementation
/// that ships with Substrate. This value may change in the future. /// that ships with Substrate. This value may change in the future.
pub const MAX_LEAVES_PER_LEVEL_SENSIBLE_DEFAULT: usize = 32; pub const MAX_LEAVES_PER_LEVEL_SENSIBLE_DEFAULT: usize = 32;
@@ -100,9 +102,10 @@ where
let info = self.backend.blockchain().info(); let info = self.backend.blockchain().info();
log::debug!( log::debug!(
target: "parachain", target: LOG_TARGET,
"Restoring chain level monitor from last finalized block: {} {}", "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; self.lowest_level = info.finalized_number;
@@ -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. /// Check and enforce the limit bound at the given height.
@@ -161,7 +168,7 @@ where
let remove_count = level_len - self.level_limit + 1; let remove_count = level_len - self.level_limit + 1;
log::debug!( log::debug!(
target: "parachain", target: LOG_TARGET,
"Detected leaves overflow at height {number}, removing {remove_count} obsolete blocks", "Detected leaves overflow at height {number}, removing {remove_count} obsolete blocks",
); );
@@ -224,9 +231,11 @@ where
}), }),
Err(err) => { Err(err) => {
log::warn!( log::warn!(
target: "parachain", target: LOG_TARGET,
"(Lookup) Unable getting route from {:?} to {:?}: {}", "(Lookup) Unable getting route from {:?} to {:?}: {}",
blk_hash, leaf_hash, err, blk_hash,
leaf_hash,
err,
); );
None None
}, },
@@ -243,7 +252,7 @@ where
None => { None => {
// This should never happen // This should never happen
log::error!( log::error!(
target: "parachain", target: LOG_TARGET,
"Unable getting route to any leaf from {:?} (this is a bug)", "Unable getting route to any leaf from {:?} (this is a bug)",
blk_hash, blk_hash,
); );
@@ -294,9 +303,9 @@ where
invalidated_leaves: &mut HashSet<usize>, invalidated_leaves: &mut HashSet<usize>,
) { ) {
let mut remove_leaf = |number, hash| { 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) { 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 return false
} }
self.levels.get_mut(&number).map(|level| level.remove(&hash)); self.levels.get_mut(&number).map(|level| level.remove(&hash));
@@ -337,9 +346,11 @@ where
}, },
Err(err) => { Err(err) => {
log::warn!( log::warn!(
target: "parachain", target: LOG_TARGET,
"(Removal) unable getting route from {:?} to {:?}: {}", "(Removal) unable getting route from {:?} to {:?}: {}",
target_hash, leaf_hash, err, target_hash,
leaf_hash,
err,
); );
}, },
_ => (), _ => (),