Allow passing multiple --log CLI options (#5982)

* Allow passing multiple --log CLI options

* Comment typo
This commit is contained in:
Pierre Krieger
2020-05-12 11:46:06 +02:00
committed by GitHub
parent 70923cdf7c
commit 0690bb51a8
3 changed files with 11 additions and 8 deletions
+1 -1
View File
@@ -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()),*
}
+7 -4
View File
@@ -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.
@@ -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(())
}
@@ -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 {
@@ -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
}
}