From 05a0af6b741d23356ef78e030054da5409296684 Mon Sep 17 00:00:00 2001 From: Cyrille Nofficial Date: Sat, 18 Dec 2021 17:57:31 +0100 Subject: [PATCH] refactor(log): zap/flag integration --- cmd/rc-steering/rc-steering.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/cmd/rc-steering/rc-steering.go b/cmd/rc-steering/rc-steering.go index dfa475c..9b93a16 100644 --- a/cmd/rc-steering/rc-steering.go +++ b/cmd/rc-steering/rc-steering.go @@ -21,8 +21,6 @@ func main() { var modelPath string var edgeVerbosity int var imgWidth, imgHeight, horizon int - var debug bool - mqttQos := cli.InitIntFlag("MQTT_QOS", 0) _, mqttRetain := os.LookupEnv("MQTT_RETAIN") @@ -36,20 +34,16 @@ func main() { flag.IntVar(&imgWidth, "img-width", 0, "image width expected by model (mandatory)") flag.IntVar(&imgHeight, "img-height", 0, "image height expected by model (mandatory)") flag.IntVar(&horizon, "horizon", 0, "upper zone to crop from image. Models expect size 'imgHeight - horizon'") - flag.BoolVar(&debug, "debug", false, "Display debug logs") - + logLevel := zap.LevelFlag("log", zap.InfoLevel, "log level") flag.Parse() + if len(os.Args) <= 1 { flag.PrintDefaults() os.Exit(1) } config := zap.NewDevelopmentConfig() - if debug { - config.Level = zap.NewAtomicLevelAt(zap.DebugLevel) - } else { - config.Level = zap.NewAtomicLevelAt(zap.InfoLevel) - } + config.Level = zap.NewAtomicLevelAt(*logLevel) lgr, err := config.Build() if err != nil { log.Fatalf("unable to init logger: %v", err)