rust-cli / rust-cli/env_logger

Always exclude certain dependencies from logging

Open
#234 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Rust
Stars
1.1k
Forks
149
Avg merge
2h 42m
Merged PRs (30d)
4

Description

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?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading env_logger::Builder::from_default_env and the filter() behavior, then reproduce the interaction with RUST_LOG=debug and explicit filters for html5ever and tantivy. Done means documenting or implementing a defined precedence rule where explicit filters can remain disabled while the environment configures other logging.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
observability
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.