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

Log levels higher than "V(1)" cannot be enabled #2350

Closed
jpeach opened this issue Jul 12, 2021 · 1 comment · Fixed by #2351
Closed

Log levels higher than "V(1)" cannot be enabled #2350

jpeach opened this issue Jul 12, 2021 · 1 comment · Fixed by #2351

Comments

@jpeach
Copy link
Contributor

jpeach commented Jul 12, 2021

Summary

When I enabled --log-level=debug, I was expecting to see log output for call sites that use log.V(2).Info(...), but nothing appears.

This patch demonstrated the problem:

-- app/kuma-cp/cmd/run.go
+++ app/kuma-cp/cmd/run.go
@@ -93,6 +93,10 @@ func newRunCmdWithOpts(opts runCmdOpts) *cobra.Command {
                                        "minimim-open-files", minOpenFileLimit)
                        }
 
+                       if !runLog.V(2).Enabled() {
+                               panic("V(2) not enabled")
+                       }
+
                        switch cfg.Mode {
                        case config_core.Standalone:
                                if err := mads_server.SetupServer(rt); err != nil {
$ kuma-cp
2021-07-12T15:38:19.115+1000	INFO	Skipping reading config from file
2021-07-12T15:38:19.115+1000	INFO	bootstrap.auto-configure	directory /home/jpeach/.kuma will be used as a working directory, it could be changed using KUMA_GENERAL_WORK_DIR environment variable
...
2021-07-12T15:38:19.117+1000	INFO	kuma-cp.run	Running in mode `standalone`
panic: V(2) not enabled

goroutine 1 [running]:
github.com/kumahq/kuma/app/kuma-cp/cmd.newRunCmdWithOpts.func1(0xc000baef00, 0xc0003d3390, 0x0, 0x1, 0x0, 0x0)
	/home/jpeach/upstream/konghq/kuma/app/kuma-cp/cmd/run.go:97 +0x1be5
github.com/spf13/cobra.(*Command).execute(0xc000baef00, 0xc0003d3380, 0x1, 0x1, 0xc000baef00, 0xc0003d3380)
	/home/jpeach/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:852 +0x472
github.com/spf13/cobra.(*Command).ExecuteC(0xc000baec80, 0x41af01, 0x0, 0x0)
	/home/jpeach/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:960 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
	/home/jpeach/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:897
github.com/kumahq/kuma/app/kuma-cp/cmd.Execute()
	/home/jpeach/upstream/konghq/kuma/app/kuma-cp/cmd/root.go:73 +0x2a
main.main()
	/home/jpeach/upstream/konghq/kuma/app/kuma-cp/main.go:6 +0x25

@jpeach jpeach added the bug label Jul 12, 2021
@jpeach
Copy link
Contributor Author

jpeach commented Jul 12, 2021

This happens because zap.DebugLevel is -1. When we pass the level down from V(2), zapr converts that to -2. The "enabled" check fails because -2 is not >= -1.

jpeach added a commit that referenced this issue Jul 12, 2021
When we are in debug logging mode, update the underlying zap log level
so that verbose logs up to level 10 will be emitted.

This fixes #2350.

Signed-off-by: James Peach <james.peach@konghq.com>
mergify bot pushed a commit that referenced this issue Jul 12, 2021
When we are in debug logging mode, update the underlying zap log level
so that verbose logs up to level 10 will be emitted.

This fixes #2350.

Signed-off-by: James Peach <james.peach@konghq.com>
(cherry picked from commit 3a950af)
jpeach added a commit that referenced this issue Jul 13, 2021
When we are in debug logging mode, update the underlying zap log level
so that verbose logs up to level 10 will be emitted.

This fixes #2350.

Signed-off-by: James Peach <james.peach@konghq.com>
(cherry picked from commit 3a950af)

Co-authored-by: James Peach <james.peach@konghq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant