Skip to content

Commit

Permalink
🍱 fix log nightmare
Browse files Browse the repository at this point in the history
  • Loading branch information
max.lerebourg committed Apr 30, 2024
1 parent 980a03c commit e2f7d83
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -479,9 +479,9 @@ http:
enabled: false
logLevel: DEBUG
updateIntervalSeconds: 60
updateMaxFailure: 0
defaultDecisionSeconds: 60
httpTimeoutSeconds: 10
updateMaxFailure: 0
crowdsecMode: live
crowdsecAppsecEnabled: false
crowdsecAppsecHost: crowdsec:7422
Expand Down
7 changes: 3 additions & 4 deletions bouncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,14 +360,13 @@ func handleNextServeHTTP(bouncer *Bouncer, remoteIP string, rw http.ResponseWrit
}

func handleStreamTicker(bouncer *Bouncer) {
bouncer.log.Debug(fmt.Sprintf("handleStreamTicker:start isCrowdsecStreamHealthy:%t", isCrowdsecStreamHealthy))
if err := handleStreamCache(bouncer); err != nil {
bouncer.log.Debug(fmt.Sprintf("handleStreamTicker:%d failure to reach crowdsec", updateFailure))
if updateFailure >= bouncer.updateMaxFailure && bouncer.updateMaxFailure != -1 {
bouncer.log.Debug(fmt.Sprintf("handleStreamTicker updateFailure:%d isCrowdsecStreamHealthy:%t %s", updateFailure, isCrowdsecStreamHealthy, err.Error()))
if bouncer.updateMaxFailure != -1 && updateFailure >= bouncer.updateMaxFailure && isCrowdsecStreamHealthy {
isCrowdsecStreamHealthy = false
bouncer.log.Error(fmt.Sprintf("handleStreamTicker:error updateFailure:%d %s", updateFailure, err.Error()))
}
updateFailure++
bouncer.log.Error(err.Error())
} else {
isCrowdsecStreamHealthy = true
updateFailure = 0
Expand Down

0 comments on commit e2f7d83

Please sign in to comment.