cargo-embed icon indicating copy to clipboard operation
cargo-embed copied to clipboard

Turning off logging doesn't work

Open WaffleLapkin opened this issue 1 year ago • 2 comments

Describe the bug You can't turn off logging via Embed.toml.

To Reproduce Steps to reproduce the behavior:

  1. Write the following to Embed.toml
    [default.general]
    log_level = "OFF"
    
  2. Run cargo embed
  3. Observe an error:
           Error Failed to parse supplied configuration:
                 unknown variant: found `OFF`, expected `one of `ERROR`, `WARN`, `INFO`, `DEBUG`, `TRACE`` for key "default.general.log_level" in Embed.toml TOML file
    

Expected behavior log_level = "OFF" turns off logging, as suggested by default.toml.

Desktop:

  • (Arch) Linux

WaffleLapkin avatar Sep 06 '22 00:09 WaffleLapkin

Yes, this is a mistake in the comment. To turn logging off, just remove 'log_level' :)

Yatekii avatar Sep 06 '22 10:09 Yatekii

@Yatekii how would it work though? log_level is defined as a log::Level (not optional) which can't ever be "off". : https://github.com/probe-rs/cargo-embed/blob/050a121dd1f66d9d097686cc2d4512e5e539220d/src/config/mod.rs#L70

Config is also merged with default.toml: https://github.com/probe-rs/cargo-embed/blob/050a121dd1f66d9d097686cc2d4512e5e539220d/src/config/mod.rs#L107

... which has the "WARN" level by default: https://github.com/probe-rs/cargo-embed/blob/050a121dd1f66d9d097686cc2d4512e5e539220d/src/config/default.toml#L41

Maybe log::LevelFilter was meant to be used instead?

WaffleLapkin avatar Sep 06 '22 12:09 WaffleLapkin