@marcel91200 / caddy Mirror · read-only / commits / eda54c22
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

logging: ⚠️ Deprecate logfmt encoder

It is essentially broken because it occludes many log fields. See: https://github.com/caddyserver/caddy/issues/3575

Matthew Holt committed Jul 13, 2020 at 16:18 UTC eda54c22a6f43d542b1e6a6532e8542ddf5eec34
1 file changed +11 -1
modules/logging/encoders.go
+11 -1
@@ -119,6 +119,13 @@ func (je *JSONEncoder) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
119
120 // LogfmtEncoder encodes log entries as logfmt:
121 // https://www.brandur.org/logfmt
122 +//
123 +// Note that logfmt does not encode nested structures
124 +// properly, so it is not a good fit for most logs.
125 +//
126 +// ⚠️ DEPRECATED. Do not use. It will eventually be removed
127 +// from the standard Caddy modules. For more information,
128 +// see https://github.com/caddyserver/caddy/issues/3575.
129 type LogfmtEncoder struct {
130 zapcore.Encoder `json:"-"`
131 LogEncoderConfig
@@ -133,7 +140,10 @@ func (LogfmtEncoder) CaddyModule() caddy.ModuleInfo {
140 }
141
142 // Provision sets up the encoder.
136 -func (lfe *LogfmtEncoder) Provision(_ caddy.Context) error {
143 +func (lfe *LogfmtEncoder) Provision(ctx caddy.Context) error {
144 + ctx.Logger(lfe).Warn("the logfmt encoder is DEPRECATED and will soon be removed from the standard modules",
145 + zap.String("recommendation", "switch to a log format that isn't broken"),
146 + zap.String("more_info", "https://github.com/caddyserver/caddy/issues/3575"))
147 lfe.Encoder = zaplogfmt.NewEncoder(lfe.ZapcoreEncoderConfig())
148 return nil
149 }