diff --git a/config.example.toml b/config.example.toml index 5757a292..b8bf78a4 100644 --- a/config.example.toml +++ b/config.example.toml @@ -60,6 +60,11 @@ # Extra Home Manager arguments #home_manager_arguments = ["--flake", "file"] +# Extra tracing filter directives +# These are prepended to the `--log-filter` argument +# See: https://docs.rs/tracing-subscriber/latest/tracing_subscriber/filter/struct.EnvFilter.html#directives +#log_filters = ["topgrade::command=debug", "warn"] + # Commands to run before anything [pre_commands] #"Emacs Snapshot" = "rm -rf ~/.emacs.d/elpa.bak && cp -rl ~/.emacs.d/elpa ~/.emacs.d/elpa.bak" diff --git a/src/config.rs b/src/config.rs index a6f28069..ffe21589 100644 --- a/src/config.rs +++ b/src/config.rs @@ -436,6 +436,8 @@ pub struct Misc { only: Option>, no_self_update: Option, + + log_filters: Option>, } #[derive(Deserialize, Default, Debug, Merge)] @@ -832,14 +834,6 @@ impl CommandLineArgs { pub fn env_variables(&self) -> &Vec { &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 } diff --git a/src/main.rs b/src/main.rs index b2eea8f6..b5193d34 100644 --- a/src/main.rs +++ b/src/main.rs @@ -64,8 +64,6 @@ fn run() -> Result<()> { return Ok(()); } - install_tracing(&opt.tracing_filter_directives())?; - for env in opt.env_variables() { let mut splitted = env.split('='); let var = splitted.next().unwrap(); @@ -84,6 +82,7 @@ fn run() -> Result<()> { } let config = Config::load(opt)?; + install_tracing(&config.tracing_filter_directives())?; set_title(config.set_title()); display_time(config.display_time()); set_desktop_notifications(config.notify_each_step());