Skip to content

Commit

Permalink
Avoid spamming logs when device has vanished
Browse files Browse the repository at this point in the history
  • Loading branch information
j-vizcaino committed Sep 26, 2019
1 parent 3571fd5 commit 6138d59
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
}
}

Expand Down

0 comments on commit 6138d59

Please sign in to comment.