log: allow SetLevel to accept Level values - #22
Open
thaJeztah wants to merge 1 commit into
Open
Conversation
thaJeztah
force-pushed
the
better_level
branch
4 times, most recently
from
August 14, 2026 09:06
c96f66d to
b098eaa
Compare
thaJeztah
marked this pull request as ready for review
August 14, 2026 09:09
vvoland
reviewed
Aug 14, 2026
| return err | ||
| // | ||
| // SetLevel returns an error if a string level is not supported. | ||
| func SetLevel[T levelValue](level T) error { |
There was a problem hiding this comment.
My only concern is that now it's impossible to assign this to a function-value without instantiation.
So if someone depends on passing log.SetLevel anywhere - it will fail now
Member
Author
There was a problem hiding this comment.
Yeah, can probably still pass it as log.SetLevel[string].
I doubt it's used like that, but I can check if there's any cases where it'd break (but also, ultimately, this whole module was meant to be for transitioning, so it should only be relevant to existing uses in containerd, moby 🤔)
Make SetLevel generic so callers can pass either a string or a Level directly. Keep the existing string parsing behavior and global logger level synchronization unchanged. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
thaJeztah
force-pushed
the
better_level
branch
from
August 14, 2026 17:34
b098eaa to
e6a4734
Compare
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.
Make SetLevel generic so callers can pass either a string or a Level directly.
Keep the existing string parsing behavior and global logger level synchronization unchanged.