@marcel91200 / caddy Mirror · read-only / commits / ef544832
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: Remove logfmt encoder (close #3575)

Has been deprecated for about 6 months now because it is broken.

Matthew Holt committed Jan 7, 2021 at 14:29 UTC ef5448324948537bb4ce798567d79d0612d41220
2 files changed -57
go.mod
-1
@@ -10,7 +10,6 @@ require (
10 github.com/dustin/go-humanize v1.0.1-0.20200219035652-afde56e7acac
11 github.com/go-chi/chi v4.1.2+incompatible
12 github.com/google/cel-go v0.6.0
13 - github.com/jsternberg/zap-logfmt v1.2.0
13 github.com/klauspost/compress v1.11.3
14 github.com/klauspost/cpuid/v2 v2.0.1
15 github.com/lucas-clemente/quic-go v0.19.3
modules/logging/encoders.go
-56
@@ -22,7 +22,6 @@ import (
22
23 "github.com/caddyserver/caddy/v2"
24 "github.com/caddyserver/caddy/v2/caddyconfig/caddyfile"
25 - zaplogfmt "github.com/jsternberg/zap-logfmt"
25 "go.uber.org/zap"
26 "go.uber.org/zap/buffer"
27 "go.uber.org/zap/zapcore"
@@ -31,7 +30,6 @@ import (
30 func init() {
31 caddy.RegisterModule(ConsoleEncoder{})
32 caddy.RegisterModule(JSONEncoder{})
34 - caddy.RegisterModule(LogfmtEncoder{})
33 caddy.RegisterModule(SingleFieldEncoder{})
34 }
35
@@ -117,58 +115,6 @@ func (je *JSONEncoder) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
115 return nil
116 }
117
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
132 -}
133 -
134 -// CaddyModule returns the Caddy module information.
135 -func (LogfmtEncoder) CaddyModule() caddy.ModuleInfo {
136 - return caddy.ModuleInfo{
137 - ID: "caddy.logging.encoders.logfmt",
138 - New: func() caddy.Module { return new(LogfmtEncoder) },
139 - }
140 -}
141 -
142 -// Provision sets up the encoder.
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 -}
150 -
151 -// UnmarshalCaddyfile sets up the module from Caddyfile tokens. Syntax:
152 -//
153 -// logfmt {
154 -// <common encoder config subdirectives...>
155 -// }
156 -//
157 -// See the godoc on the LogEncoderConfig type for the syntax of
158 -// subdirectives that are common to most/all encoders.
159 -func (lfe *LogfmtEncoder) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
160 - for d.Next() {
161 - if d.NextArg() {
162 - return d.ArgErr()
163 - }
164 - err := lfe.LogEncoderConfig.UnmarshalCaddyfile(d)
165 - if err != nil {
166 - return err
167 - }
168 - }
169 - return nil
170 -}
171 -
118 // SingleFieldEncoder writes a log entry that consists entirely
119 // of a single string field in the log entry. This is useful
120 // for custom, self-encoded log entries that consist of a
@@ -398,11 +344,9 @@ var bufferpool = buffer.NewPool()
344 var (
345 _ zapcore.Encoder = (*ConsoleEncoder)(nil)
346 _ zapcore.Encoder = (*JSONEncoder)(nil)
401 - _ zapcore.Encoder = (*LogfmtEncoder)(nil)
347 _ zapcore.Encoder = (*SingleFieldEncoder)(nil)
348
349 _ caddyfile.Unmarshaler = (*ConsoleEncoder)(nil)
350 _ caddyfile.Unmarshaler = (*JSONEncoder)(nil)
406 - _ caddyfile.Unmarshaler = (*LogfmtEncoder)(nil)
351 _ caddyfile.Unmarshaler = (*SingleFieldEncoder)(nil)
352 )