Use LOG_TARGET in consensus related crates (#12875)

* Use shared LOG_TARGET in consensus related crates
* Rename target from "afg" to "grandpa"
This commit is contained in:
Davide Galassi
2022-12-14 14:56:17 +01:00
committed by GitHub
parent 3e0a1904b7
commit 391adaf443
31 changed files with 343 additions and 247 deletions
+9 -7
View File
@@ -48,6 +48,8 @@ use std::{
time::{Duration, Instant},
};
const LOG_TARGET: &str = "slots";
/// The changes that need to applied to the storage to create the state for a block.
///
/// See [`sp_state_machine::StorageChanges`] for more information.
@@ -198,9 +200,9 @@ pub trait SimpleSlotWorker<B: BlockT> {
> {
let slot = slot_info.slot;
let telemetry = self.telemetry();
let logging_target = self.logging_target();
let log_target = self.logging_target();
let inherent_data = Self::create_inherent_data(&slot_info, &logging_target).await?;
let inherent_data = Self::create_inherent_data(&slot_info, &log_target).await?;
let proposing_remaining_duration = self.proposing_remaining_duration(&slot_info);
let logs = self.pre_digest_data(slot, claim);
@@ -220,19 +222,19 @@ pub trait SimpleSlotWorker<B: BlockT> {
let proposal = match futures::future::select(proposing, proposing_remaining).await {
Either::Left((Ok(p), _)) => p,
Either::Left((Err(err), _)) => {
warn!(target: logging_target, "Proposing failed: {}", err);
warn!(target: log_target, "Proposing failed: {}", err);
return None
},
Either::Right(_) => {
info!(
target: logging_target,
target: log_target,
"⌛️ Discarding proposal for slot {}; block production took too long", slot,
);
// If the node was compiled with debug, tell the user to use release optimizations.
#[cfg(build_type = "debug")]
info!(
target: logging_target,
target: log_target,
"👉 Recompile your node in `--release` mode to mitigate this problem.",
);
telemetry!(
@@ -525,13 +527,13 @@ pub async fn start_slot_worker<B, C, W, SO, CIDP, Proof>(
let slot_info = match slots.next_slot().await {
Ok(r) => r,
Err(e) => {
warn!(target: "slots", "Error while polling for next slot: {}", e);
warn!(target: LOG_TARGET, "Error while polling for next slot: {}", e);
return
},
};
if sync_oracle.is_major_syncing() {
debug!(target: "slots", "Skipping proposal slot due to sync.");
debug!(target: LOG_TARGET, "Skipping proposal slot due to sync.");
continue
}
@@ -20,7 +20,7 @@
//!
//! This is used instead of `futures_timer::Interval` because it was unreliable.
use super::{InherentDataProviderExt, Slot};
use super::{InherentDataProviderExt, Slot, LOG_TARGET};
use sp_consensus::{Error, SelectChain};
use sp_inherents::{CreateInherentDataProviders, InherentDataProvider};
use sp_runtime::traits::{Block as BlockT, Header as HeaderT};
@@ -146,7 +146,7 @@ where
Ok(x) => x,
Err(e) => {
log::warn!(
target: "slots",
target: LOG_TARGET,
"Unable to author block in slot. No best block header: {}",
e,
);