VictoriaMetrics/lib/logger/flag.go

31 lines
648 B
Go
Raw Normal View History

2019-05-22 21:16:55 +00:00
package logger
import (
"flag"
"strings"
"github.com/VictoriaMetrics/VictoriaMetrics/lib/buildinfo"
"github.com/VictoriaMetrics/VictoriaMetrics/lib/flagutil"
2019-05-22 21:16:55 +00:00
)
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
})
2019-05-22 21:16:55 +00:00
flag.VisitAll(func(f *flag.Flag) {
lname := strings.ToLower(f.Name)
value := f.Value.String()
if flagutil.IsSecretFlag(lname) {
2019-05-22 21:16:55 +00:00
value = "secret"
}
isSet := "false"
if isSetMap[f.Name] {
isSet = "true"
}
Infof("flag %q=%q (is_set=%s)", f.Name, value, isSet)
2019-05-22 21:16:55 +00:00
})
}