Cli: Introduce --detailed-log-output flag (#10278)

* Cli: Introduce `--detailed-log-output` flag

If this CLI flag is given, detailed log output will be enabled. This includes the log level, log
target ad the thread name. Before this was only enabled when a log level higher than `info` should
be logged.

* Update client/tracing/src/logging/mod.rs

Co-authored-by: David <dvdplm@gmail.com>

Co-authored-by: David <dvdplm@gmail.com>
This commit is contained in:
Bastian Köcher
2021-11-16 14:01:35 +01:00
committed by GitHub
parent 363dbbe8da
commit 12cf771a7a
3 changed files with 59 additions and 17 deletions
+8 -1
View File
@@ -547,6 +547,11 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
Ok(self.shared_params().log_filters().join(","))
}
/// Should the detailed log output be enabled.
fn detailed_log_output(&self) -> Result<bool> {
Ok(self.shared_params().detailed_log_output())
}
/// Is log reloading enabled?
fn enable_log_reloading(&self) -> Result<bool> {
Ok(self.shared_params().enable_log_reloading())
@@ -568,7 +573,9 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
sp_panic_handler::set(&C::support_url(), &C::impl_version());
let mut logger = LoggerBuilder::new(self.log_filters()?);
logger.with_log_reloading(self.enable_log_reloading()?);
logger
.with_log_reloading(self.enable_log_reloading()?)
.with_detailed_output(self.detailed_log_output()?);
if let Some(tracing_targets) = self.tracing_targets()? {
let tracing_receiver = self.tracing_receiver()?;
@@ -49,6 +49,14 @@ pub struct SharedParams {
#[structopt(short = "l", long, value_name = "LOG_PATTERN")]
pub log: Vec<String>,
/// Enable detailed log output.
///
/// This includes displaying the log target, log level and thread name.
///
/// This is automatically enabled when something is logged with any higher level than `info`.
#[structopt(long)]
pub detailed_log_output: bool,
/// Disable log color output.
#[structopt(long)]
pub disable_log_color: bool,
@@ -107,6 +115,11 @@ impl SharedParams {
&self.log
}
/// Should the detailed log output be enabled.
pub fn detailed_log_output(&self) -> bool {
self.detailed_log_output
}
/// Should the log color output be disabled?
pub fn disable_log_color(&self) -> bool {
self.disable_log_color