emabee / flexi_logger

A flexible logger for rust programs that can write to stderr, stdout, and/or to log files
Apache License 2.0
307 stars 50 forks source link

Different log level for crates #78

Closed incker closed 3 years ago

incker commented 3 years ago

Hello,

Is it possible to make different log levels for crates? For example my project - debug, all dependable crates - warn. And are there plans to make this feature?

Forward thank you

emabee commented 3 years ago

Yes, that is easy to achieve! I should revise the docu,, the code examples in fact don't mention this important aspect. But there is some documentation, see LogSpecification.

With

Logger::try_with_str("warn, my_crate=debug")?.start()?;

you get exactly what you want, provided that your crate has the name "my_crate" ;-) The "warn" alone defines the default trace level, the "my_crate=debug" specifies the deviating value for your crate.