mirror of https://github.com/caddyserver/caddy.git
fastcgi: Add debug log (#3178)
This commit is contained in:
parent
9af05719bc
commit
745cb0e9e6
|
@ -29,6 +29,7 @@ import (
|
||||||
"github.com/caddyserver/caddy/v2/modules/caddyhttp"
|
"github.com/caddyserver/caddy/v2/modules/caddyhttp"
|
||||||
"github.com/caddyserver/caddy/v2/modules/caddyhttp/reverseproxy"
|
"github.com/caddyserver/caddy/v2/modules/caddyhttp/reverseproxy"
|
||||||
"github.com/caddyserver/caddy/v2/modules/caddytls"
|
"github.com/caddyserver/caddy/v2/modules/caddytls"
|
||||||
|
"go.uber.org/zap"
|
||||||
|
|
||||||
"github.com/caddyserver/caddy/v2"
|
"github.com/caddyserver/caddy/v2"
|
||||||
)
|
)
|
||||||
|
@ -66,6 +67,7 @@ type Transport struct {
|
||||||
WriteTimeout caddy.Duration `json:"write_timeout,omitempty"`
|
WriteTimeout caddy.Duration `json:"write_timeout,omitempty"`
|
||||||
|
|
||||||
serverSoftware string
|
serverSoftware string
|
||||||
|
logger *zap.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
// CaddyModule returns the Caddy module information.
|
// CaddyModule returns the Caddy module information.
|
||||||
|
@ -77,7 +79,8 @@ func (Transport) CaddyModule() caddy.ModuleInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Provision sets up t.
|
// 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 == "" {
|
if t.Root == "" {
|
||||||
t.Root = "{http.vars.root}"
|
t.Root = "{http.vars.root}"
|
||||||
}
|
}
|
||||||
|
@ -110,6 +113,12 @@ func (t Transport) RoundTrip(r *http.Request) (*http.Response, error) {
|
||||||
address = dialInfo.Address
|
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)
|
fcgiBackend, err := DialContext(ctx, network, address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// TODO: wrap in a special error type if the dial failed, so retries can happen if enabled
|
// TODO: wrap in a special error type if the dial failed, so retries can happen if enabled
|
||||||
|
|
Loading…
Reference in New Issue