Skip to content

Commit

Permalink
Split (potentially sensitive) details to a trace-level log
Browse files Browse the repository at this point in the history
  • Loading branch information
glpatcern committed Jun 23, 2023
1 parent 88890b0 commit 520fbea
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions internal/http/interceptors/log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,16 @@ func writeLog(log *zerolog.Logger, req *http.Request, url url.URL, ts time.Time,
var event *zerolog.Event
switch {
case status < 400:
event = log.Debug()
event = log.Info()
case status < 500:
event = log.Warn()
default:
event = log.Error()
}
event.Str("host", host).Str("method", req.Method).Str("uri", uri).Int("status", status).
Msg("processed http request")

event.Str("host", host).Str("method", req.Method).
log.Trace().Str("host", host).Str("method", req.Method).
Str("uri", uri).Str("proto", req.Proto).Interface("req_headers", req.Header).
Int("status", status).Int("size", size).Interface("res_headers", resHeaders).
Str("start", ts.Format("02/Jan/2006:15:04:05 -0700")).
Expand Down

0 comments on commit 520fbea

Please sign in to comment.