diff --git a/cmd/thalos/main.go b/cmd/thalos/main.go index c8d2473..020681b 100644 --- a/cmd/thalos/main.go +++ b/cmd/thalos/main.go @@ -163,6 +163,14 @@ func getChain(def string) string { return def } +func LogLevels() []string { + list := []string{} + for _, lvl := range log.AllLevels { + list = append(list, lvl.String()) + } + return list +} + func main() { var err error var chainInfo *eos.InfoResp @@ -174,6 +182,7 @@ func main() { configFile := getopt.StringLong("config", 'c', "./config.yml", "Config file to read", "file") pidFile := getopt.StringLong("pid", 'p', "", "Where to write process id", "file") logFile := getopt.StringLong("log", 'l', "", "Path to log file", "file") + logLevel := getopt.EnumLong("level", 'L', LogLevels(), "info", "Log level to use") getopt.Parse() @@ -210,6 +219,14 @@ func main() { conf.Log.Filename = path.Base(*logFile) } + lvl, err := log.ParseLevel(*logLevel) + if err == nil { + log.WithField("value", lvl).Info("Setting log level") + log.SetLevel(lvl) + } else { + log.WithError(err).Warn("Failed to parse level") + } + if len(conf.Log.Filename) > 0 { stdWriter, err := NewRotatingFileFromConfig(conf.Log, "info") if err != nil {