From eda54c22a6f43d542b1e6a6532e8542ddf5eec34 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Mon, 13 Jul 2020 16:18:34 -0600 Subject: =?UTF-8?q?logging:=20=E2=9A=A0=EF=B8=8F=20Deprecate=20logfmt=20en?= =?UTF-8?q?coder?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It is essentially broken because it occludes many log fields. See: https://github.com/caddyserver/caddy/issues/3575 --- modules/logging/encoders.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/logging/encoders.go b/modules/logging/encoders.go index bd120d5..79382df 100644 --- a/modules/logging/encoders.go +++ b/modules/logging/encoders.go @@ -119,6 +119,13 @@ func (je *JSONEncoder) UnmarshalCaddyfile(d *caddyfile.Dispenser) error { // LogfmtEncoder encodes log entries as logfmt: // https://www.brandur.org/logfmt +// +// Note that logfmt does not encode nested structures +// properly, so it is not a good fit for most logs. +// +// ⚠️ DEPRECATED. Do not use. It will eventually be removed +// from the standard Caddy modules. For more information, +// see https://github.com/caddyserver/caddy/issues/3575. type LogfmtEncoder struct { zapcore.Encoder `json:"-"` LogEncoderConfig @@ -133,7 +140,10 @@ func (LogfmtEncoder) CaddyModule() caddy.ModuleInfo { } // Provision sets up the encoder. -func (lfe *LogfmtEncoder) Provision(_ caddy.Context) error { +func (lfe *LogfmtEncoder) Provision(ctx caddy.Context) error { + ctx.Logger(lfe).Warn("the logfmt encoder is DEPRECATED and will soon be removed from the standard modules", + zap.String("recommendation", "switch to a log format that isn't broken"), + zap.String("more_info", "https://github.com/caddyserver/caddy/issues/3575")) lfe.Encoder = zaplogfmt.NewEncoder(lfe.ZapcoreEncoderConfig()) return nil } -- cgit v1.2.3