From 6138d5964568006822eb21b6754cc3a90b1617ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Vizcaino?= Date: Thu, 26 Sep 2019 21:59:14 +0200 Subject: [PATCH] Avoid spamming logs when device has vanished --- main.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 58fcda8..5a8c015 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,7 @@ package main import ( "flag" + "io" "github.com/DataDog/datadog-go/statsd" "github.com/j-vizcaino/goteleinfo" log "github.com/sirupsen/logrus" @@ -25,9 +26,12 @@ func readFrames(reader teleinfo.Reader, framesChan chan teleinfo.Frame) { f, err := reader.ReadFrame() if err != nil { log.WithField("error", err).Warn("Teleinfo frame read failed") - } else { - framesChan <- f + if err == io.EOF { + log.Fatal("Device handle is closed, stopping application") + } + continue } + framesChan <- f } }