Skip to content

Unable to print Warn Logs when using logr/zapr #258

@warber

Description

@warber

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":

zapLogger, _ := zap.NewProduction()
logger := zapr.NewLogger(zapLogger)
logger.V(-1).Info("Hello")

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

if level < 0 {

On the zapr side i also find a code section like that: https://github.com/go-logr/zapr/blob/544fccbab1b69101aec26b69db60f876a95e3f12/zapr.go#L187

Where it also seems that non negative numbers are expected.

That leaves me with the question: How can I print logs with Warn level?

Thanks

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions