Skip to content

Commit

Permalink
Hide location printing for defmt frames behind another verbosity level.
Browse files Browse the repository at this point in the history
  • Loading branch information
whitequark committed Jun 20, 2023
1 parent e8b4cb8 commit c15ecb8
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,19 @@ pub fn handle_arguments() -> anyhow::Result<i32> {
let opts = Opts::parse();
let verbose = opts.verbose;

defmt_decoder::log::init_logger(verbose >= 1, opts.json, move |metadata| {
defmt_decoder::log::init_logger(verbose >= 1, verbose >= 2, opts.json, move |metadata| {
if defmt_decoder::log::is_defmt_frame(metadata) {
true // We want to display *all* defmt frames.
} else {
// Log depending on how often the `--verbose` (`-v`) cli-param is supplied:
// * 0: log everything from probe-run, with level "info" or higher
// * 1: log everything from probe-run
// * 2 or more: log everything
// * 0 to 1: log everything from probe-run, with level "info" or higher
// * 2: log everything from probe-run
// * 3 or more: log everything
match verbose {
0 => metadata.target().starts_with("probe_run") && metadata.level() <= Level::Info,
1 => metadata.target().starts_with("probe_run"),
0..=1 => {
metadata.target().starts_with("probe_run") && metadata.level() <= Level::Info
}
2 => metadata.target().starts_with("probe_run"),
_ => true,
}
}
Expand Down

0 comments on commit c15ecb8

Please sign in to comment.