@marcel91200 / caddy Mirror · read-only / commits / 745cb0e9
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 14, 05:15 UTC

fastcgi: Add debug log (#3178)

Matthew Holt committed Mar 24, 2020 at 08:34 UTC 745cb0e9e646b6a4b1bf3b366a4a8352cdb722cd
1 file changed +10 -1
modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go
+10 -1
@@ -29,6 +29,7 @@ import (
29 "github.com/caddyserver/caddy/v2/modules/caddyhttp"
30 "github.com/caddyserver/caddy/v2/modules/caddyhttp/reverseproxy"
31 "github.com/caddyserver/caddy/v2/modules/caddytls"
32 + "go.uber.org/zap"
33
34 "github.com/caddyserver/caddy/v2"
35 )
@@ -66,6 +67,7 @@ type Transport struct {
67 WriteTimeout caddy.Duration `json:"write_timeout,omitempty"`
68
69 serverSoftware string
70 + logger *zap.Logger
71 }
72
73 // CaddyModule returns the Caddy module information.
@@ -77,7 +79,8 @@ func (Transport) CaddyModule() caddy.ModuleInfo {
79 }
80
81 // Provision sets up t.
80 -func (t *Transport) Provision(_ caddy.Context) error {
82 +func (t *Transport) Provision(ctx caddy.Context) error {
83 + t.logger = ctx.Logger(t)
84 if t.Root == "" {
85 t.Root = "{http.vars.root}"
86 }
@@ -110,6 +113,12 @@ func (t Transport) RoundTrip(r *http.Request) (*http.Response, error) {
113 address = dialInfo.Address
114 }
115
116 + t.logger.Debug("roundtrip",
117 + zap.Object("request", caddyhttp.LoggableHTTPRequest{Request: r}),
118 + zap.String("dial", address),
119 + zap.Any("env", env), // TODO: this uses reflection I think
120 + )
121 +
122 fcgiBackend, err := DialContext(ctx, network, address)
123 if err != nil {
124 // TODO: wrap in a special error type if the dial failed, so retries can happen if enabled