Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set default level #162

Open
RalfJung opened this issue Jun 16, 2020 · 1 comment
Open

Set default level #162

RalfJung opened this issue Jun 16, 2020 · 1 comment

Comments

@RalfJung
Copy link

RalfJung commented Jun 16, 2020

The docs recommend the following snippet to set the default level to, e.g., "warn":

env_logger::from_env(Env::default().default_filter_or("warn")).init();

However, this does not work as expected: what I would expect is that when setting RUST_LOG=some::module=info, all the other modules are still subject to the default level, "warn". However, default_filter_or says

Use the default environment variable to read the filter from.

If the variable is not set, the default value will be used.

So, once RUST_LOG is set, the default for all unspecified modules is "error" again.

Is there any way to truly change the default level for unspecified modules? If not, this is a feature request to add such an option. :)

@KodrAus
Copy link
Collaborator

KodrAus commented Jul 1, 2020

Ah it sounds like the way Env is only focused on reading and substituting stringly-typed environment variables is surprising for filters, where the value is a list. Since all other methods using filters are additive I think your expected behaviour of adding the default and reading from the environment makes the most sense here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants