Skip to content

Commit

Permalink
Merge pull request #32480 from vespa-engine/arnej/logfmt-show-all-levels
Browse files Browse the repository at this point in the history
vespa-logfmt now shows all levels by default;
  • Loading branch information
arnej27959 authored Sep 27, 2024
2 parents 3e66346 + 37c21f9 commit fa393bb
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
12 changes: 7 additions & 5 deletions client/go/internal/admin/vespa-wrapper/logfmt/levelflags.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ func defaultLevelFlags() map[string]bool {
"error": true,
"warning": true,
"info": true,
"config": false,
"event": false,
"debug": false,
"spam": false,
"config": true,
"event": true,
"debug": true,
"spam": true,
}
}

Expand Down Expand Up @@ -68,5 +68,7 @@ func (v *flagValueForLevel) unchanged() bool {
}

func (v *flagValueForLevel) Set(val string) error {
return applyPlusMinus(val, v)
err := applyPlusMinus(val, v)
v.changed = true
return err
}
13 changes: 7 additions & 6 deletions client/go/internal/admin/vespa-wrapper/logfmt/levelflags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,19 @@ func TestLevelFlags(t *testing.T) {
t.Fail()
}
}
check(" +fatal +error +warning +info -config -event -debug -spam")
check(" +fatal +error +warning +info +config +event +debug +spam")
check(" -fatal -error -warning -info -config -event -debug -spam", "-all")
check(" +fatal +error +warning +info +config +event +debug +spam", "all")
check(" +fatal +error +warning +info +config +event +debug +spam", "+all")
check(" -fatal -error -warning -info -config -event +debug -spam", "debug")
check(" +fatal +error +warning +info +config +event +debug -spam", "all-spam")
check(" +fatal +error +warning +info +config +event +debug -spam", "all", "-spam")
check(" +fatal +error +warning -info -config +event -debug -spam", "+event", "-info")
check(" +fatal +error -warning -info -config +event -debug -spam", "+event,-info,-warning,config")
check(" +fatal +error -warning -info +config +event -debug -spam", "+event,-info,-warning,+config")
check(" +fatal +error -warning -info +config +event -debug -spam", "+event,-info", "-warning,+config")
check(" -fatal -error -warning -info +config -event -debug -spam", "+event", "-info", "-warning", "config")
check(" +fatal +error +warning -info +config +event +debug +spam", "+event", "-info")
check(" +fatal +error -warning -info -config +event +debug +spam", "+event,-info,-warning,config")
check(" +fatal +error -warning -info +config +event +debug +spam", "+event,-info,-warning,+config")
check(" +fatal +error -warning -info +config +event +debug +spam", "+event,-info", "-warning,+config")
check(" +fatal +error -warning -info +config +event +debug +spam", "+event", "-info", "-warning", "config")
check(" -fatal +error -warning +info -config -event +debug -spam", "info", "debug", "error")
check = func(expectErr string, texts ...string) {
var target flagValueForLevel
target.levels = defaultLevelFlags()
Expand Down
4 changes: 3 additions & 1 deletion client/go/internal/admin/vespa-wrapper/logfmt/showflags.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,7 @@ func (v *flagValueForShow) unchanged() bool {
}

func (v *flagValueForShow) Set(val string) error {
return applyPlusMinus(val, v)
err := applyPlusMinus(val, v)
v.changed = true
return err
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ func TestShowFlags(t *testing.T) {
check(" +time -fmttime +msecs -usecs +host +level -pid -service +component +message", "+host,-fmttime,-service,pid")
check(" +time -fmttime +msecs -usecs +host +level +pid -service +component +message", "+host,-fmttime,-service,+pid")
check(" +time -fmttime +msecs -usecs +host +level +pid -service +component +message", "+host,-fmttime", "-service,+pid")
check(" -time -fmttime -msecs -usecs -host -level +pid -service -component -message", "+host", "-fmttime", "-service", "pid")
check(" +time -fmttime +msecs -usecs +host +level +pid -service +component +message", "+host", "-fmttime", "-service", "pid")
check(" -time -fmttime -msecs -usecs +host -level +pid -service +component -message", "host", "component", "pid")
check = func(expectErr string, texts ...string) {
var target flagValueForShow
target.shown = defaultShowFlags()
Expand Down

0 comments on commit fa393bb

Please sign in to comment.