Only report battery sensor errors once; closes #117

This commit is contained in:
Sean E. Russell 2020-05-31 14:45:24 -05:00
parent e8727c7c20
commit 5123568b92
2 changed files with 8 additions and 2 deletions

View File

@ -61,6 +61,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- There were a number of minor issues with the config file that have been cleaned up.
- Compile errors on FreeBSD due to golang.org/x/sys API breakages
- Key bindings now work in FreeBSD (#95)
- Only report battery sensor errors once (reduce noise in the log, #117)
## [3.5.3] - 2020-05-30

View File

@ -39,11 +39,16 @@ func (b *BatteryGauge) EnableMetric() {
})
}
// Only report battery errors once.
var errLogged = false
func (b *BatteryGauge) update() {
// FIXME: Getting a lot of these in the logs
bats, err := battery.GetAll()
if err != nil {
log.Printf("error setting up batteries: %v", err)
if !errLogged {
log.Printf("error setting up batteries: %v", err)
errLogged = true
}
return
}
mx := 0.0