Skip to content

Commit

Permalink
caddyhttp: Log non-500 handler errors at debug level (#4429)
Browse files Browse the repository at this point in the history
Fixes #4428

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.
  • Loading branch information
francislavoie committed Nov 22, 2021
1 parent 7d5047c commit eead337
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions modules/caddyhttp/server.go
Expand Up @@ -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
Expand All @@ -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)
}
Expand Down

0 comments on commit eead337

Please sign in to comment.