Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Allow passing multiple --log CLI options #5982

Merged
merged 2 commits into from
May 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ macro_rules! substrate_cli_subcommands {
}
}

fn log_filters(&self) -> $crate::Result<::std::option::Option<String>> {
fn log_filters(&self) -> $crate::Result<String> {
match self {
$($enum::$variant(cmd) => cmd.log_filters()),*
}
Expand Down
11 changes: 7 additions & 4 deletions client/cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,9 +472,12 @@ pub trait CliConfiguration: Sized {

/// Get the filters for the logging.
///
/// This should be a list of comma-separated values.
/// Example: `foo=trace,bar=debug,baz=info`
///
/// By default this is retrieved from `SharedParams`.
fn log_filters(&self) -> Result<Option<String>> {
Ok(self.shared_params().log_filters())
fn log_filters(&self) -> Result<String> {
Ok(self.shared_params().log_filters().join(","))
}

/// Initialize substrate. This must be done only once.
Expand All @@ -485,12 +488,12 @@ pub trait CliConfiguration: Sized {
/// 2. Raise the FD limit
/// 3. Initialize the logger
fn init<C: SubstrateCli>(&self) -> Result<()> {
let logger_pattern = self.log_filters()?.unwrap_or_default();
let logger_pattern = self.log_filters()?;

sp_panic_handler::set(C::support_url(), C::impl_version());

fdlimit::raise_fd_limit();
init_logger(logger_pattern.as_str());
init_logger(&logger_pattern);

Ok(())
}
Expand Down
6 changes: 3 additions & 3 deletions client/cli/src/params/shared_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub struct SharedParams {
/// Log levels (least to most verbose) are error, warn, info, debug, and trace.
/// By default, all targets log `info`. The global log level can be set with -l<level>.
#[structopt(short = "l", long = "log", value_name = "LOG_PATTERN")]
pub log: Option<String>,
pub log: Vec<String>,
}

impl SharedParams {
Expand Down Expand Up @@ -71,7 +71,7 @@ impl SharedParams {
}

/// Get the filters for the logging
pub fn log_filters(&self) -> Option<String> {
self.log.clone()
pub fn log_filters(&self) -> &[String] {
&self.log
}
}