sc-informant: Respect --disable-log-color (#3009)

Changes `sc-informant` to respect the `--disable-log-color` CLI flag.

Closes: https://github.com/paritytech/polkadot-sdk/issues/2795

---------

Co-authored-by: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com>
This commit is contained in:
Bastian KöcherandMichal Kucharczyk authored and GitHub committed 2024-01-22 10:31:37 +00:00
1 parent d53534c49e
commit deb72f432d
5 files changed
+82 -45

No files matched your search

+14 -31
View File
@@ -142,37 +142,20 @@ impl<B: BlockT> InformantDisplay<B> {
("⚙️ ", format!("Preparing{}", speed), format!(", target=#{target}")),
};
if self.format.enable_color {
info!(
target: "substrate",
"{} {}{} ({} peers), best: #{} ({}), finalized #{} ({}), {} {}",
level,
Colour::White.bold().paint(&status),
target,
Colour::White.bold().paint(format!("{}", num_connected_peers)),
Colour::White.bold().paint(format!("{}", best_number)),
best_hash,
Colour::White.bold().paint(format!("{}", finalized_number)),
info.chain.finalized_hash,
Colour::Green.paint(format!("⬇ {}", TransferRateFormat(avg_bytes_per_sec_inbound))),
Colour::Red.paint(format!("⬆ {}", TransferRateFormat(avg_bytes_per_sec_outbound))),
)
} else {
info!(
target: "substrate",
"{} {}{} ({} peers), best: #{} ({}), finalized #{} ({}), ⬇ {} ⬆ {}",
level,
status,
target,
num_connected_peers,
best_number,
best_hash,
finalized_number,
info.chain.finalized_hash,
TransferRateFormat(avg_bytes_per_sec_inbound),
TransferRateFormat(avg_bytes_per_sec_outbound),
)
}
info!(
target: "substrate",
"{} {}{} ({} peers), best: #{} ({}), finalized #{} ({}), {} {}",
level,
self.format.print_with_color(Colour::White.bold(), status),
target,
self.format.print_with_color(Colour::White.bold(), num_connected_peers),
self.format.print_with_color(Colour::White.bold(), best_number),
best_hash,
self.format.print_with_color(Colour::White.bold(), finalized_number),
info.chain.finalized_hash,
self.format.print_with_color(Colour::Green, format!("⬇ {}", TransferRateFormat(avg_bytes_per_sec_inbound))),
self.format.print_with_color(Colour::Red, format!("⬆ {}", TransferRateFormat(avg_bytes_per_sec_outbound))),
)
}
}