rust-cli / env_logger

A logging implementation for `log` which is configured via an environment variable.
https://docs.rs/env_logger
Apache License 2.0
826 stars 128 forks source link

Add `Builder::try_parse()` method #324

Closed Maximkaaa closed 3 months ago

Maximkaaa commented 3 months ago

Current implementation of the Builder::parse() method prints out specification errors to stderr and then just ignores them. This is fine for most console applications, but in some cases better control over what is happening is needed:

For such cases this PR introduces a new method try_parse that does the same thing as the parse method, but returns an Err in case an error in the specification is found.

This change was suggested in and fixes #323.

coveralls commented 3 months ago

Pull Request Test Coverage Report for Build 10060325859

Details


Changes Missing Coverage Covered Lines Changed/Added Lines %
crates/env_filter/src/filter.rs 5 12 41.67%
crates/env_filter/src/parser.rs 7 28 25.0%
<!-- Total: 12 40 30.0% -->
Totals Coverage Status
Change from base Build 9504345986: -1.0%
Covered Lines: 245
Relevant Lines: 576

💛 - Coveralls
epage commented 3 months ago

Thanks for moving this forward!

Maximkaaa commented 3 months ago

I fixed all the comments except the last one, since I think that the current approach is better. If you insist on returning just one error string, I will edit it also.

epage commented 3 months ago

Looks like the final commit needs cargo fmt run on it

Maximkaaa commented 3 months ago

Looks like the final commit needs cargo fmt run on it

Done.

epage commented 3 months ago

Thanks! This is now released.