mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-10 17:11:03 +00:00
Add node name to the log lines (#7328)
* Initial commit Forked at:601e2fa139Parent branch: origin/master * WIP Forked at:601e2fa139Parent branch: origin/master * WIP Forked at:601e2fa139Parent branch: origin/master * WIP Forked at:601e2fa139Parent branch: origin/master * WIP Forked at:601e2fa139Parent branch: origin/master * WIP Forked at:601e2fa139Parent branch: origin/master * CLEANUP Forked at:601e2fa139Parent branch: origin/master * Add notes to original source code * CLEANUP Forked at:601e2fa139Parent branch: origin/master * CLEANUP Forked at:601e2fa139Parent branch: origin/master * WIP Forked at:601e2fa139Parent branch: origin/master * WIP Forked at:601e2fa139Parent branch: origin/master * WIP Forked at:601e2fa139Parent branch: origin/master * CLEANUP Forked at:601e2fa139Parent branch: origin/master * WIP Forked at:601e2fa139Parent branch: origin/master * Some doc * Test with trybuild * Revert "Test with trybuild" (issue with trybuild atm) This reverts commit 9055ec2206808ba3ddce6e3d87eb358907fa5e42. https://github.com/dtolnay/trybuild/issues/53 * Apply suggestions * Rename derive to proc-macro * Remove "prefix" feature from informant * Blocking task should use SpawnHandle::spawn_blocking * Improve doc as suggested * Fixes Forked at:601e2fa139Parent branch: origin/master * Apply suggestion * Update client/cli/proc-macro/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * More suggestions * CLEANUP Forked at:601e2fa139Parent branch: origin/master * Improve error message * CLEANUP Forked at:601e2fa139Parent branch: origin/master * Fix async issue * CLEANUP Forked at:601e2fa139Parent branch: origin/master * CLEANUP Forked at:601e2fa139Parent branch: origin/master * Add test * fix doc test * Update client/cli/src/logging.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/basic-authorship/src/basic_authorship.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/basic-authorship/src/basic_authorship.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Apply suggestions * Suggestions * Clarify doc * WIP Forked at:601e2fa139Parent branch: origin/master Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -104,9 +104,8 @@ impl<B: BlockT> InformantDisplay<B> {
|
||||
if self.format.enable_color {
|
||||
info!(
|
||||
target: "substrate",
|
||||
"{} {}{}{} ({} peers), best: #{} ({}), finalized #{} ({}), {} {}",
|
||||
"{} {}{} ({} peers), best: #{} ({}), finalized #{} ({}), {} {}",
|
||||
level,
|
||||
self.format.prefix,
|
||||
Colour::White.bold().paint(&status),
|
||||
target,
|
||||
Colour::White.bold().paint(format!("{}", num_connected_peers)),
|
||||
@@ -120,9 +119,8 @@ impl<B: BlockT> InformantDisplay<B> {
|
||||
} else {
|
||||
info!(
|
||||
target: "substrate",
|
||||
"{} {}{}{} ({} peers), best: #{} ({}), finalized #{} ({}), ⬇ {} ⬆ {}",
|
||||
"{} {}{} ({} peers), best: #{} ({}), finalized #{} ({}), ⬇ {} ⬆ {}",
|
||||
level,
|
||||
self.format.prefix,
|
||||
status,
|
||||
target,
|
||||
num_connected_peers,
|
||||
|
||||
@@ -37,29 +37,12 @@ mod display;
|
||||
pub struct OutputFormat {
|
||||
/// Enable color output in logs. True by default.
|
||||
pub enable_color: bool,
|
||||
/// Defines the informant's prefix for the logs. An empty string by default.
|
||||
///
|
||||
/// By default substrate will show logs without a prefix. Example:
|
||||
///
|
||||
/// ```text
|
||||
/// 2020-05-28 15:11:06 ✨ Imported #2 (0xc21c…2ca8)
|
||||
/// 2020-05-28 15:11:07 💤 Idle (0 peers), best: #2 (0xc21c…2ca8), finalized #0 (0x7299…e6df), ⬇ 0 ⬆ 0
|
||||
/// ```
|
||||
///
|
||||
/// But you can define a prefix by setting this string. This will output:
|
||||
///
|
||||
/// ```text
|
||||
/// 2020-05-28 15:11:06 ✨ [Prefix] Imported #2 (0xc21c…2ca8)
|
||||
/// 2020-05-28 15:11:07 💤 [Prefix] Idle (0 peers), best: #2 (0xc21c…2ca8), finalized #0 (0x7299…e6df), ⬇ 0 ⬆ 0
|
||||
/// ```
|
||||
pub prefix: String,
|
||||
}
|
||||
|
||||
impl Default for OutputFormat {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
enable_color: true,
|
||||
prefix: String::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -118,14 +101,11 @@ where
|
||||
|
||||
future::join(
|
||||
display_notifications,
|
||||
display_block_import(client, format.prefix),
|
||||
display_block_import(client),
|
||||
).map(|_| ())
|
||||
}
|
||||
|
||||
fn display_block_import<B: BlockT, C>(
|
||||
client: Arc<C>,
|
||||
prefix: String,
|
||||
) -> impl Future<Output = ()>
|
||||
fn display_block_import<B: BlockT, C>(client: Arc<C>) -> impl Future<Output = ()>
|
||||
where
|
||||
C: UsageProvider<B> + HeaderMetadata<B> + BlockchainEvents<B>,
|
||||
<C as HeaderMetadata<B>>::Error: Display,
|
||||
@@ -151,8 +131,7 @@ where
|
||||
|
||||
match maybe_ancestor {
|
||||
Ok(ref ancestor) if ancestor.hash != *last_hash => info!(
|
||||
"♻️ {}Reorg on #{},{} to #{},{}, common ancestor #{},{}",
|
||||
prefix,
|
||||
"♻️ Reorg on #{},{} to #{},{}, common ancestor #{},{}",
|
||||
Colour::Red.bold().paint(format!("{}", last_num)), last_hash,
|
||||
Colour::Green.bold().paint(format!("{}", n.header.number())), n.hash,
|
||||
Colour::White.bold().paint(format!("{}", ancestor.number)), ancestor.hash,
|
||||
@@ -179,8 +158,7 @@ where
|
||||
|
||||
info!(
|
||||
target: "substrate",
|
||||
"✨ {}Imported #{} ({})",
|
||||
prefix,
|
||||
"✨ Imported #{} ({})",
|
||||
Colour::White.bold().paint(format!("{}", n.header.number())),
|
||||
n.hash,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user