caddyhttp: Log non-500 handler errors at debug level ()

Fixes 

It's best to still log handler errors at debug level so that they're hidden by default, but still accessible if additional details are necessary.
This commit is contained in:
Francis Lavoie 2021-11-22 13:58:25 -05:00 committed by GitHub
parent 7d5047c1f1
commit eead337324
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -244,6 +244,8 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// successfully, so now just log the error
if errStatus >= 500 {
logger.Error(errMsg, errFields...)
} else {
logger.Debug(errMsg, errFields...)
}
} else {
// well... this is awkward
@ -262,6 +264,8 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
} else {
if errStatus >= 500 {
logger.Error(errMsg, errFields...)
} else {
logger.Debug(errMsg, errFields...)
}
w.WriteHeader(errStatus)
}