smarter structured logs

This commit is contained in:
m5r
2024-07-28 12:15:59 +02:00
parent 1797bca311
commit cd2ed76903
2 changed files with 17 additions and 7 deletions

View File

@ -20,7 +20,11 @@ func loggingMiddleware(w http.ResponseWriter, r *http.Request, next http.Handler
start := time.Now()
next(w, r)
response := w.(negroni.ResponseWriter)
utils.Logger.Debug().Str("FLY_REGION", flyRegion).Msgf("%s %s %d %s", r.Method, r.URL.Path, response.Status(), time.Since(start))
logEvent := utils.Logger.Debug()
if flyRegion != "" {
logEvent.Str("FLY_REGION", flyRegion)
}
logEvent.Msgf("%s %s %d %s", r.Method, r.URL.Path, response.Status(), time.Since(start))
}
func newHttpMux() http.Handler {