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
803 stars 125 forks source link

Add a fitler parsing function returning `Result` instead of writing errors to `stderr` #323

Closed Maximkaaa closed 1 month ago

Maximkaaa commented 1 month ago

I suggest adding a new method env_filter::filter::try_parse(&mut self, filters: &str) -> Result<&mut Self, ParsingError>. This would imply adding a new ParsingError type and a small refactoring, but would make the library more convenient in some situations.

In my use case, I don't have access to the contents of stderr when the application is starting, and I actually don't want the application to start if the logger is configured incorrectly. Such a method would let me do this without copying the parser implementation to the application code.

If the maintainers agree that this can be added to the env_logger, I am happy to create a PR.

epage commented 1 month ago

I think its a reasonable addition.