diff options
author | Matthew Holt <[email protected]> | 2020-03-24 08:34:15 -0600 |
---|---|---|
committer | Matthew Holt <[email protected]> | 2020-03-24 08:34:15 -0600 |
commit | 745cb0e9e646b6a4b1bf3b366a4a8352cdb722cd (patch) | |
tree | a429fe39dbe0123f07ad20a2b1c409260ac65f5d | |
parent | 9af05719bc99e36001d86c1f9af7015d856334b0 (diff) | |
download | caddy-745cb0e9e646b6a4b1bf3b366a4a8352cdb722cd.tar.gz caddy-745cb0e9e646b6a4b1bf3b366a4a8352cdb722cd.zip |
fastcgi: Add debug log (#3178)
-rw-r--r-- | modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go b/modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go index 11900c1ad..cff6b391e 100644 --- a/modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go +++ b/modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go @@ -29,6 +29,7 @@ import ( "github.com/caddyserver/caddy/v2/modules/caddyhttp" "github.com/caddyserver/caddy/v2/modules/caddyhttp/reverseproxy" "github.com/caddyserver/caddy/v2/modules/caddytls" + "go.uber.org/zap" "github.com/caddyserver/caddy/v2" ) @@ -66,6 +67,7 @@ type Transport struct { WriteTimeout caddy.Duration `json:"write_timeout,omitempty"` serverSoftware string + logger *zap.Logger } // CaddyModule returns the Caddy module information. @@ -77,7 +79,8 @@ func (Transport) CaddyModule() caddy.ModuleInfo { } // Provision sets up t. -func (t *Transport) Provision(_ caddy.Context) error { +func (t *Transport) Provision(ctx caddy.Context) error { + t.logger = ctx.Logger(t) if t.Root == "" { t.Root = "{http.vars.root}" } @@ -110,6 +113,12 @@ func (t Transport) RoundTrip(r *http.Request) (*http.Response, error) { address = dialInfo.Address } + t.logger.Debug("roundtrip", + zap.Object("request", caddyhttp.LoggableHTTPRequest{Request: r}), + zap.String("dial", address), + zap.Any("env", env), // TODO: this uses reflection I think + ) + fcgiBackend, err := DialContext(ctx, network, address) if err != nil { // TODO: wrap in a special error type if the dial failed, so retries can happen if enabled |