refacto(log): configure log level
This commit is contained in:
parent
1a3b9916d0
commit
2cc7ee5070
@ -17,7 +17,6 @@ func main() {
|
|||||||
var mqttBroker, username, password, clientId, topicBase, topicRoi string
|
var mqttBroker, username, password, clientId, topicBase, topicRoi string
|
||||||
var pubFrequency, horizon int
|
var pubFrequency, horizon int
|
||||||
var device, videoWidth, videoHeight int
|
var device, videoWidth, videoHeight int
|
||||||
var debug bool
|
|
||||||
|
|
||||||
mqttQos := cli.InitIntFlag("MQTT_QOS", 0)
|
mqttQos := cli.InitIntFlag("MQTT_QOS", 0)
|
||||||
_, mqttRetain := os.LookupEnv("MQTT_RETAIN")
|
_, mqttRetain := os.LookupEnv("MQTT_RETAIN")
|
||||||
@ -37,20 +36,16 @@ func main() {
|
|||||||
|
|
||||||
flag.IntVar(&horizon, "horizon", horizon, "Limit region of interest to horizon in pixels from top, use HORIZON if args not set")
|
flag.IntVar(&horizon, "horizon", horizon, "Limit region of interest to horizon in pixels from top, use HORIZON if args not set")
|
||||||
|
|
||||||
flag.BoolVar(&debug, "debug", false, "Display raw value to debug")
|
logLevel := zap.LevelFlag("log", zap.InfoLevel, "log level")
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
if len(os.Args) <= 1 {
|
if len(os.Args) <= 1 {
|
||||||
flag.PrintDefaults()
|
flag.PrintDefaults()
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
config := zap.NewDevelopmentConfig()
|
config := zap.NewDevelopmentConfig()
|
||||||
if debug {
|
config.Level = zap.NewAtomicLevelAt(*logLevel)
|
||||||
config.Level = zap.NewAtomicLevelAt(zap.DebugLevel)
|
|
||||||
} else {
|
|
||||||
config.Level = zap.NewAtomicLevelAt(zap.InfoLevel)
|
|
||||||
}
|
|
||||||
lgr, err := config.Build()
|
lgr, err := config.Build()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("unable to init logger: %v", err)
|
log.Fatalf("unable to init logger: %v", err)
|
||||||
@ -73,7 +68,7 @@ func main() {
|
|||||||
videoProperties[gocv.VideoCaptureFrameHeight] = float64(videoHeight)
|
videoProperties[gocv.VideoCaptureFrameHeight] = float64(videoHeight)
|
||||||
|
|
||||||
if topicRoi == "" {
|
if topicRoi == "" {
|
||||||
topicRoi = fmt.Sprintf( "%s-roi", topicBase)
|
topicRoi = fmt.Sprintf("%s-roi", topicBase)
|
||||||
}
|
}
|
||||||
c := camera.New(client, topicBase, topicRoi, pubFrequency, videoProperties, horizon)
|
c := camera.New(client, topicBase, topicRoi, pubFrequency, videoProperties, horizon)
|
||||||
defer c.Stop()
|
defer c.Stop()
|
||||||
|
Loading…
Reference in New Issue
Block a user