Feature: only log health when health state changes

This commit is contained in:
Quentin McGaw
2021-02-09 02:45:50 +00:00
parent 84787f0ea2
commit b0bd06bdc5
2 changed files with 3 additions and 2 deletions

View File

@@ -29,7 +29,6 @@ func (h *handler) ServeHTTP(responseWriter http.ResponseWriter, request *http.Re
return return
} }
if err := h.getErr(); err != nil { if err := h.getErr(); err != nil {
h.logger.Error(err)
http.Error(responseWriter, err.Error(), http.StatusInternalServerError) http.Error(responseWriter, err.Error(), http.StatusInternalServerError)
return return
} }

View File

@@ -19,7 +19,9 @@ func (s *server) runHealthcheckLoop(ctx context.Context, wg *sync.WaitGroup) {
s.handler.setErr(err) s.handler.setErr(err)
if previousErr != nil && err == nil { if previousErr != nil && err == nil {
s.logger.Info("passed") s.logger.Info("healthy!")
} else if previousErr == nil && err != nil {
s.logger.Info("unhealthy: " + err.Error())
} }
if err != nil { // try again after 1 second if err != nil { // try again after 1 second