Skip to content

Commit

Permalink
Merge pull request #84 from stevekuznetsov/skuznets/better-logging
Browse files Browse the repository at this point in the history
handlers: stop double-logging errors
  • Loading branch information
k8s-ci-robot authored May 21, 2021
2 parents faafeaa + 1b4e32c commit 36bb085
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions handlers/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,13 +415,12 @@ func handleMetric(r *ranch.Ranch) http.HandlerFunc {
}

func returnAndLogError(res http.ResponseWriter, err error, logMsg string) {
logMsg = fmt.Sprintf("%s: %v", logMsg, err)
log := logrus.WithError(err)
httpStatus := errorToStatus(err)
if httpStatus > 499 {
log.Error(logMsg)
} else {
log.Debug(logMsg)
}
http.Error(res, logMsg, httpStatus)
http.Error(res, fmt.Sprintf("%s: %v", logMsg, err), httpStatus)
}

0 comments on commit 36bb085

Please sign in to comment.