diff --git a/cmd/rc-led/rc-led.go b/cmd/rc-led/rc-led.go index 09fe180..9fd2a81 100644 --- a/cmd/rc-led/rc-led.go +++ b/cmd/rc-led/rc-led.go @@ -16,7 +16,6 @@ const ( func main() { var mqttBroker, username, password, clientId string var driveModeTopic, recordTopic string - var debug bool mqttQos := cli.InitIntFlag("MQTT_QOS", 0) _, mqttRetain := os.LookupEnv("MQTT_RETAIN") @@ -26,20 +25,16 @@ func main() { flag.StringVar(&driveModeTopic, "mqtt-topic-drive-mode", os.Getenv("MQTT_TOPIC_DRIVE_MODE"), "Mqtt topic that contains DriveMode value, use MQTT_TOPIC_DRIVE_MODE if args not set") flag.StringVar(&recordTopic, "mqtt-topic-record", os.Getenv("MQTT_TOPIC_RECORD"), "Mqtt topic that contains video recording state, use MQTT_TOPIC_RECORD if args not set") - flag.BoolVar(&debug, "debug", false, "Display raw value to debug") - + 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)