summaryrefslogtreecommitdiffhomepage
path: root/modules
diff options
context:
space:
mode:
authorMatthew Holt <[email protected]>2020-05-18 14:08:11 -0600
committerMatthew Holt <[email protected]>2020-05-18 14:08:11 -0600
commit9ee01dceac0a3e9f71c3b37dfbe3ae04e2f54986 (patch)
tree51a55c2abf88d17b0b58e3714f137e464c0faddd /modules
parent812278acd8a5c46b44fdf92ea5df4d6a51eff7be (diff)
downloadcaddy-9ee01dceac0a3e9f71c3b37dfbe3ae04e2f54986.tar.gz
caddy-9ee01dceac0a3e9f71c3b37dfbe3ae04e2f54986.zip
reverseproxy: Make debug log safe if error occurs
Diffstat (limited to 'modules')
-rw-r--r--modules/caddyhttp/reverseproxy/reverseproxy.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/modules/caddyhttp/reverseproxy/reverseproxy.go b/modules/caddyhttp/reverseproxy/reverseproxy.go
index 52d230c72..3bf881e45 100644
--- a/modules/caddyhttp/reverseproxy/reverseproxy.go
+++ b/modules/caddyhttp/reverseproxy/reverseproxy.go
@@ -461,20 +461,24 @@ func (h *Handler) reverseProxy(rw http.ResponseWriter, req *http.Request, di Dia
// point the request to this upstream
h.directRequest(req, di)
- // do the round-trip
+ // do the round-trip; emit debug log with values we know are
+ // safe, or if there is no error, emit fuller log entry
start := time.Now()
res, err := h.Transport.RoundTrip(req)
duration := time.Since(start)
- h.logger.Debug("upstream roundtrip",
+ logger := h.logger.With(
zap.String("upstream", di.Upstream.String()),
zap.Object("request", caddyhttp.LoggableHTTPRequest{Request: req}),
- zap.Object("headers", caddyhttp.LoggableHTTPHeader(res.Header)),
zap.Duration("duration", duration),
- zap.Int("status", res.StatusCode),
)
if err != nil {
+ logger.Debug("upstream roundtrip", zap.Error(err))
return err
}
+ logger.Debug("upstream roundtrip",
+ zap.Object("headers", caddyhttp.LoggableHTTPHeader(res.Header)),
+ zap.Int("status", res.StatusCode),
+ )
// update circuit breaker on current conditions
if di.Upstream.cb != nil {