feat: allow setting misc.log_filters in config.toml (#552)

Allow setting `log_filters` in `config.toml`

This allows setting a list of `log_filters` in the `[misc]` section in
the `config.toml`. These filters are prepended to any filters listed
with `--log-filters`. Finally, `--verbose` can now be used with
`--log-filters`, and it will append `debug` to the list of filters
rather than replacing it entirely.
This commit is contained in:
Rebecca Turner
2023-09-17 03:04:46 -04:00
committed by GitHub
parent 06a6b7a2eb
commit c1c9fe22df
3 changed files with 21 additions and 10 deletions

View File

@@ -436,6 +436,8 @@ pub struct Misc {
only: Option<Vec<Step>>,
no_self_update: Option<bool>,
log_filters: Option<Vec<String>>,
}
#[derive(Deserialize, Default, Debug, Merge)]
@@ -832,14 +834,6 @@ impl CommandLineArgs {
pub fn env_variables(&self) -> &Vec<String> {
&self.env
}
pub fn tracing_filter_directives(&self) -> String {
if self.verbose {
"debug".into()
} else {
self.log_filter.clone()
}
}
}
/// Represents the application configuration
@@ -1390,6 +1384,19 @@ impl Config {
self.opt.verbose
}
pub fn tracing_filter_directives(&self) -> String {
let mut ret = String::new();
if let Some(directives) = self.config_file.misc.as_ref().and_then(|m| m.log_filters.as_ref()) {
ret.push_str(&directives.join(","));
}
ret.push(',');
ret.push_str(&self.opt.log_filter);
if self.verbose() {
ret.push_str(",debug");
}
ret
}
pub fn show_skipped(&self) -> bool {
self.opt.show_skipped
}