Add per-module log level filtering#9
Open
oubiwann wants to merge 1 commit into
Open
Conversation
Allow users to suppress noisy third-party crates while keeping verbose logging for their own code, similar to RUST_LOG=info,tokenizers=warn. New Opts field `module_filters: Vec<(String, LogLevel)>` with builder methods `module_filter()` and `module_filters()`. Filters match log record targets by prefix; first match wins. The effective max level passed to log::set_max_level() is the most permissive among global + all filter levels so messages still reach the custom enabled() check. Closes #8 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
module_filtersfield toOptsandOptsBuilderfor per-module log level overrideslevellog::set_max_level()set to the most permissive level across global + all filters so messages reach the customenabled()checkExample usage
This suppresses
tokenizersTRACE/DEBUG/INFO while keeping TRACE for everything else.Files changed
src/opts.rsmodule_filtersfield onOpts+OptsBuilder, accessor, builder methods, serde support, 5 new testssrc/logger.rsmodule_filtersonLoggerConfig, per-module filtering inenabled(), effective max level indispatch(), 5 new testssrc/lib.rssetup()doc comment with module_filters exampleTest plan
cargo clippy -- -D warningscleancargo fmt --checkcleanlevel=Trace, module_filters=[("tokenizers", Warn)]Closes #8
🤖 Generated with Claude Code