mirror of
https://github.com/caddyserver/caddy.git
synced 2025-01-14 06:46:27 +03:00
logging: ⚠️ Deprecate logfmt encoder
It is essentially broken because it occludes many log fields. See: https://github.com/caddyserver/caddy/issues/3575
This commit is contained in:
parent
2c71fb116b
commit
eda54c22a6
1 changed files with 11 additions and 1 deletions
|
@ -119,6 +119,13 @@ func (je *JSONEncoder) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
|
||||||
|
|
||||||
// LogfmtEncoder encodes log entries as logfmt:
|
// LogfmtEncoder encodes log entries as logfmt:
|
||||||
// https://www.brandur.org/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 {
|
type LogfmtEncoder struct {
|
||||||
zapcore.Encoder `json:"-"`
|
zapcore.Encoder `json:"-"`
|
||||||
LogEncoderConfig
|
LogEncoderConfig
|
||||||
|
@ -133,7 +140,10 @@ func (LogfmtEncoder) CaddyModule() caddy.ModuleInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Provision sets up the encoder.
|
// 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())
|
lfe.Encoder = zaplogfmt.NewEncoder(lfe.ZapcoreEncoderConfig())
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue