From 0cbfea1c294748fbcddc3a406aaaf71f27ed7ac7 Mon Sep 17 00:00:00 2001 From: makhov Date: Wed, 8 Jan 2025 16:08:56 +0200 Subject: [PATCH] Respect log level from the command-line arguments --- cmd/agent/main.go | 8 +++++--- cmd/server/main.go | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/cmd/agent/main.go b/cmd/agent/main.go index 10498c9ad..af97301a1 100644 --- a/cmd/agent/main.go +++ b/cmd/agent/main.go @@ -36,9 +36,11 @@ func main() { flags.AddFlagSet(o.Flags()) local := flag.NewFlagSet(os.Args[0], flag.ExitOnError) klog.InitFlags(local) - err := local.Set("v", "4") - if err != nil { - fmt.Fprintf(os.Stderr, "error setting klog flags: %v", err) + if local.Lookup("v") == nil { + err := local.Set("v", "4") + if err != nil { + fmt.Fprintf(os.Stderr, "error setting klog flags: %v", err) + } } local.VisitAll(func(fl *flag.Flag) { fl.Name = util.Normalize(fl.Name) diff --git a/cmd/server/main.go b/cmd/server/main.go index fdb1a736b..3bad77eec 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -36,9 +36,11 @@ func main() { flags.AddFlagSet(o.Flags()) local := flag.NewFlagSet(os.Args[0], flag.ExitOnError) klog.InitFlags(local) - err := local.Set("v", "4") - if err != nil { - fmt.Fprintf(os.Stderr, "error setting klog flags: %v", err) + if local.Lookup("v") == nil { + err := local.Set("v", "4") + if err != nil { + fmt.Fprintf(os.Stderr, "error setting klog flags: %v", err) + } } local.VisitAll(func(fl *flag.Flag) { fl.Name = util.Normalize(fl.Name)