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

pkg/log/zap: development option not turning on debug logging #1228

Closed
estroz opened this issue Oct 26, 2020 · 1 comment
Closed

pkg/log/zap: development option not turning on debug logging #1228

estroz opened this issue Oct 26, 2020 · 1 comment
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@estroz
Copy link
Contributor

estroz commented Oct 26, 2020

controller-runtime v0.6.3

Setting pkg/log/zap.Options.Development = true then constructing a zap logger using the prescribed code doesn't seem to turn on debug logging (or development mode at all).

The old way (main.go):

var logger = ctrl.Log.WithName("setup")

func main() {
	ctrl.SetLogger(zap.New(zap.UseDevMode(true)))
	logger.V(1).Info("running in debug")
}

Then:

$ go run main.go
2020-10-26T16:32:04.135-0700	DEBUG	setup	running in debug

The new way (main.go):

var logger = ctrl.Log.WithName("setup")

func main() {
	opts := &zap.Options{Development: true}
	opts.BindFlags(flag.CommandLine)
	flag.Parse()
	ctrl.SetLogger(zap.New(zap.UseFlagOptions(opts)))
    logger.V(1).Info("running in debug")
}

Then:

$ go run main.go # no output

But if I set --zap-log-level=debug explicitly:

$ go run main.go --zap-log-level=debug
{"level":"debug","ts":1603755159.9834673,"logger":"setup","msg":"running in debug"}

Note how the output is JSON, which is the default production output encoding; development should give console output according to the docs.

And if I set --zap-devel explicitly:

$ go run main.go --zap-devel
2020-10-26T16:44:42.638-0700	DEBUG	setup	running in debug

/kind bug

/ping @joelanford @DirectXMan12

@estroz
Copy link
Contributor Author

estroz commented Oct 27, 2020

This looks like it was fixed by #972.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

2 participants