mirror of
https://github.com/caddyserver/caddy.git
synced 2025-10-19 07:43:17 +00:00
logging: Add support for additional logger filters other than hostname (#6082)
Co-authored-by: Francis Lavoie <lavofr@gmail.com>
This commit is contained in:
parent
4af38e5ac8
commit
4356635d12
6 changed files with 217 additions and 15 deletions
|
@ -369,7 +369,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
errLog = errLog.With(zap.Duration("duration", duration))
|
||||
errLoggers := []*zap.Logger{errLog}
|
||||
if s.Logs != nil {
|
||||
errLoggers = s.Logs.wrapLogger(errLog, r.Host)
|
||||
errLoggers = s.Logs.wrapLogger(errLog, r)
|
||||
}
|
||||
|
||||
// get the values that will be used to log the error
|
||||
|
@ -778,7 +778,7 @@ func (s *Server) logRequest(
|
|||
|
||||
loggers := []*zap.Logger{accLog}
|
||||
if s.Logs != nil {
|
||||
loggers = s.Logs.wrapLogger(accLog, r.Host)
|
||||
loggers = s.Logs.wrapLogger(accLog, r)
|
||||
}
|
||||
|
||||
// wrapping may return multiple loggers, so we log to all of them
|
||||
|
@ -835,7 +835,6 @@ func PrepareRequest(r *http.Request, repl *caddy.Replacer, w http.ResponseWriter
|
|||
ctx = context.WithValue(ctx, OriginalRequestCtxKey, originalRequest(r, &url2))
|
||||
|
||||
ctx = context.WithValue(ctx, ExtraLogFieldsCtxKey, new(ExtraLogFields))
|
||||
|
||||
r = r.WithContext(ctx)
|
||||
|
||||
// once the pointer to the request won't change
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue