fix: respect logging levels in mongodb_exporter#6050
Open
utafrali wants to merge 2 commits intografana:mainfrom
Open
fix: respect logging levels in mongodb_exporter#6050utafrali wants to merge 2 commits intografana:mainfrom
utafrali wants to merge 2 commits intografana:mainfrom
Conversation
Contributor
|
Hey thanks for the pr and I can see why the previous workarounds did not work here. But I don't want to add more wrappers. We are currently migrating to use slog in the code base see e.g. #6039. So instead we should fix the issue by finishing this migration |
Author
|
Ah got it, I'll update this to the slog migration instead then. |
Contributor
If you want to do that it would be great but you have to wait for the pr I linked to be merged first |
Author
|
Got it, I'll wait for #6039 to merge and then update this PR with the slog migration. |
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.
Describe the change:
Fixed the Enabled() method to respect logging levels. mongodb_exporter and similar libraries check Enabled() before logging to stderr, but we were always returning true which bypassed the level filter.
Detailed description:
Created a levelAwareLogger wrapper that preserves EnabledAware through log.With() chains. Now Enabled() properly delegates to the level checker instead of defaulting to true.
Which issue(s) this PR fixes: Fixes #5258
Notes for reviewers:
Simple wrapper that delegates to EnabledAware. Tests added to cover the new behavior.
Checklist: Tests updated