lib/logger: show only explicitly set command-line flags in logs

This reduces initial verbosity in logs
This commit is contained in:
Aliaksandr Valialkin 2021-10-28 11:00:49 +03:00
parent acfda6d8fd
commit d0e7c0535e
No known key found for this signature in database
GPG Key ID: A72BEC6CD3D0DED1

View File

@ -11,20 +11,12 @@ import (
func logAllFlags() {
Infof("build version: %s", buildinfo.Version)
Infof("command line flags")
isSetMap := make(map[string]bool)
flag.Visit(func(f *flag.Flag) {
isSetMap[f.Name] = true
})
flag.VisitAll(func(f *flag.Flag) {
lname := strings.ToLower(f.Name)
value := f.Value.String()
if flagutil.IsSecretFlag(lname) {
value = "secret"
}
isSet := "false"
if isSetMap[f.Name] {
isSet = "true"
}
Infof("flag %q=%q (is_set=%s)", f.Name, value, isSet)
Infof("flag %q=%q", f.Name, value)
})
}