Skip to content
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

Confusion on logging levels #4771

Closed
criscola opened this issue Apr 15, 2021 · 5 comments
Closed

Confusion on logging levels #4771

criscola opened this issue Apr 15, 2021 · 5 comments
Assignees
Labels
language/go Issue is related to a Go operator project triage/support Indicates an issue that is a support question.
Milestone

Comments

@criscola
Copy link

Type of question

Open question

Question

What did you do?

ctrl.SetLogger(zap.Level(zapcore.Level(3))))

in my Reconcile method:

logger.V(3).Info("Reconcile called")

What did you expect to see?

I expected to see "Reconcile called" in my output logs.

What did you see instead? Under which circumstances?

Nothing.

Environment

Operator type:

/language go

Additional context

If I read the docs for zapcore.Level, it says "A Level is a logging priority. Higher levels are more important.", but here's what the docs for the Logger interface is saying "[..] higher verbosity level means a log message is less important", so it looks like a contradiction.

Am I misunderstanding how the logging levels are supposed to work? To me, the intention of the Logger interface appears more sensed, but when I try to manually set the logging level of zap, the behavior is not what I expect. Sorry if this is the wrong place to ask, but as the operator-sdk automatically scaffolds zap and logr together I thought it would be appropriated to talk about it here.

How do I set the desired level of logging manually (not through BindFlag)?

@openshift-ci-robot openshift-ci-robot added the language/go Issue is related to a Go operator project label Apr 15, 2021
@kensipe kensipe self-assigned this Apr 19, 2021
@kensipe kensipe added this to the Backlog milestone Apr 19, 2021
@kensipe kensipe added the triage/support Indicates an issue that is a support question. label Apr 19, 2021
@kensipe
Copy link
Member

kensipe commented Apr 19, 2021

In the process of investigating. While this issue remains here for tracking, this is really a kubebuilder / controller-runtime issue / decision. We will get clarification which hopefully results in documentation that will be posted here.

@kensipe
Copy link
Member

kensipe commented Apr 19, 2021

@estroz
Copy link
Member

estroz commented Apr 19, 2021

TL;DR: the level should be zapcore.Level(-3).

Created a PR to help clarify this in controller-runtime: kubernetes-sigs/controller-runtime#1485

@criscola
Copy link
Author

Thank you @estroz and @kensipe, this line of godoc is going to save some head-scratching 😃.

@kensipe
Copy link
Member

kensipe commented Apr 21, 2021

for those inclined to read... I completely agree :) thanks for reporting and following up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
language/go Issue is related to a Go operator project triage/support Indicates an issue that is a support question.
Projects
None yet
Development

No branches or pull requests

4 participants