mirror of
https://github.com/caddyserver/caddy.git
synced 2025-05-28 06:40:01 +08:00
caddyhttp: Trace individual middleware handlers (#6313)
* caddyhttp: Trace individual middleware handlers * Fix typo
This commit is contained in:
@ -234,6 +234,7 @@ type Server struct {
|
||||
logger *zap.Logger
|
||||
accessLogger *zap.Logger
|
||||
errorLogger *zap.Logger
|
||||
traceLogger *zap.Logger
|
||||
ctx caddy.Context
|
||||
|
||||
server *http.Server
|
||||
@ -738,6 +739,15 @@ func (s *Server) shouldLogRequest(r *http.Request) bool {
|
||||
return !s.Logs.SkipUnmappedHosts
|
||||
}
|
||||
|
||||
// logTrace will log that this middleware handler is being invoked.
|
||||
// It emits at DEBUG level.
|
||||
func (s *Server) logTrace(mh MiddlewareHandler) {
|
||||
if s.Logs == nil || !s.Logs.Trace {
|
||||
return
|
||||
}
|
||||
s.traceLogger.Debug(caddy.GetModuleName(mh), zap.Any("module", mh))
|
||||
}
|
||||
|
||||
// logRequest logs the request to access logs, unless skipped.
|
||||
func (s *Server) logRequest(
|
||||
accLog *zap.Logger, r *http.Request, wrec ResponseRecorder, duration *time.Duration,
|
||||
|
Reference in New Issue
Block a user