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
797 stars 124 forks source link

Always exclude certain dependencies from logging #234

Open kornelski opened 2 years ago

kornelski commented 2 years ago

I'd like to have RUST_LOG env variable to work as usual, except never log anything from a couple of noisy dependencies.

I thought this would do the trick:

        let _ = env_logger::Builder::from_default_env()
            .filter(Some("html5ever"), log::LevelFilter::Off)
            .filter(Some("tantivy"), log::LevelFilter::Off)
            .try_init();

but it seems that RUST_LOG=debug enables debug output even for the dependencies I'm trying to filter out.

Is there a way to gracefully combine env vars and explicit filters, with my filter() calls taking precedence?

slientgoat commented 2 years ago

RUST_LOG=DEBUG,html5ever=off,tantivy=off

kornelski commented 2 years ago

I know it's possible to set it manually every time, but my whole point is that I would like to avoid having to do this the long way, and provide a better default. In other words I'd like: