-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to print Warn Logs when using logr/zapr #258
Comments
Right now you can't. As you noticed, logr doesn't have a concept of "more important than INFO = V(0)". Introducing such a concept would be a breaking change (LogSinks don't expect a negative level) that would have to be handled with care. I'm not sure whether that would be worth it. I'd like to allow |
I know this is philosophical but.... There's no such thing as a warning. There are only things worth logging and things not worth logging. As for -1, that seems like it would be a race to the bottom. Every library would fight to be even more important than every other library. A major part of the design was to bound what a library can emit. "I know you think you are important, but in the larger context you're just not." |
I don't think that this aspect of the design is used anywhere. At one point during the contextual logging review, Jordan pointed out that if he sees a Because this is not used, there's no incentive for library developers to do The feature that I was thinking of is that the caller decides that they want more output. The scheduler folks had "log more information about scheduling of one pod" as one of their use cases. The pseudo-code then would be |
User can already do things like:
...without any support from us |
That works if the bias is inside the code which does the log call. It does not work when code in package A is calling function Suppose component A wants to elevate all messages in that |
You can use negative numbers to Zap, and use positive numbers to logr. Here is my personal "standard" log code, and a unit-test: There are some additional things to note like formatted time, and especially |
HI, I am using "logr/zapr" combination and I am a bit confused because I am not able to print "WARN" level logs.
To my understanding the following code should result in a log message printed by zap with severity level "warning":
However, it's still printed with INFO level.
Of course it's because the V-Level is actively set back to
0
when it is negative:logr/logr.go
Line 312 in 1be0bc0
On the
zapr
side i also find a code section like that: https://github.com/go-logr/zapr/blob/544fccbab1b69101aec26b69db60f876a95e3f12/zapr.go#L187Where it also seems that non negative numbers are expected.
That leaves me with the question: How can I print logs with Warn level?
Thanks
The text was updated successfully, but these errors were encountered: