Skip to content

Commit

Permalink
Only report battery sensor errors once; closes #117
Browse files Browse the repository at this point in the history
  • Loading branch information
xxxserxxx committed May 31, 2020
1 parent e8727c7 commit 5123568
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 7 additions & 2 deletions widgets/batterygauge.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5123568

Please sign in to comment.