Skip to content

Commit 12b2481

Browse files
committed
Revert "Merge pull request #685 from makhov/respect-log-level-from-args"
This reverts commit 4ce5f06. This commit reverts a previous modification to the flag handling logic in the agent and server's main() functions. A prior change introduced a condition (`if local.Lookup("v") == nil`) before setting the default klog verbosity level. This condition was incorrect because `klog.InitFlags()` always defines the `-v` flag, meaning the default verbosity was never being applied. This caused the effective log level to fall back to klog's default of `0` instead of the intended `4`. This change restores the original, correct behavior by unconditionally setting the verbosity to `4`. This ensures logs are visible by default while still allowing the user to override the setting via the command line.
1 parent 62bba95 commit 12b2481

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

cmd/agent/main.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,9 @@ func main() {
3636
flags.AddFlagSet(o.Flags())
3737
local := flag.NewFlagSet(os.Args[0], flag.ExitOnError)
3838
klog.InitFlags(local)
39-
if local.Lookup("v") == nil {
40-
err := local.Set("v", "4")
41-
if err != nil {
42-
fmt.Fprintf(os.Stderr, "error setting klog flags: %v", err)
43-
}
39+
err := local.Set("v", "4")
40+
if err != nil {
41+
fmt.Fprintf(os.Stderr, "error setting klog flags: %v", err)
4442
}
4543
local.VisitAll(func(fl *flag.Flag) {
4644
fl.Name = util.Normalize(fl.Name)

cmd/server/main.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,9 @@ func main() {
3636
flags.AddFlagSet(o.Flags())
3737
local := flag.NewFlagSet(os.Args[0], flag.ExitOnError)
3838
klog.InitFlags(local)
39-
if local.Lookup("v") == nil {
40-
err := local.Set("v", "4")
41-
if err != nil {
42-
fmt.Fprintf(os.Stderr, "error setting klog flags: %v", err)
43-
}
39+
err := local.Set("v", "4")
40+
if err != nil {
41+
fmt.Fprintf(os.Stderr, "error setting klog flags: %v", err)
4442
}
4543
local.VisitAll(func(fl *flag.Flag) {
4644
fl.Name = util.Normalize(fl.Name)

0 commit comments

Comments
 (0)