mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-27 06:03:48 +03:00
logging: Little fix for filtering object fields
This commit is contained in:
parent
3d9f8eac08
commit
8c7c2e4af2
1 changed files with 8 additions and 0 deletions
|
@ -39,6 +39,11 @@ type FilterEncoder struct {
|
||||||
|
|
||||||
// A map of field names to their filters. Note that this
|
// A map of field names to their filters. Note that this
|
||||||
// is not a module map; the keys are field names.
|
// is not a module map; the keys are field names.
|
||||||
|
//
|
||||||
|
// Nested fields can be referenced by representing a
|
||||||
|
// layer of nesting with `>`. In other words, for an
|
||||||
|
// object like `{"a":{"b":0}}`, the inner field can
|
||||||
|
// be referenced as `a>b`.
|
||||||
FieldsRaw map[string]json.RawMessage `json:"fields,omitempty" caddy:"namespace=caddy.logging.encoders.filter inline_key=filter"`
|
FieldsRaw map[string]json.RawMessage `json:"fields,omitempty" caddy:"namespace=caddy.logging.encoders.filter inline_key=filter"`
|
||||||
|
|
||||||
wrapped zapcore.Encoder
|
wrapped zapcore.Encoder
|
||||||
|
@ -96,6 +101,9 @@ func (fe FilterEncoder) AddArray(key string, marshaler zapcore.ArrayMarshaler) e
|
||||||
|
|
||||||
// AddObject is part of the zapcore.ObjectEncoder interface.
|
// AddObject is part of the zapcore.ObjectEncoder interface.
|
||||||
func (fe FilterEncoder) AddObject(key string, marshaler zapcore.ObjectMarshaler) error {
|
func (fe FilterEncoder) AddObject(key string, marshaler zapcore.ObjectMarshaler) error {
|
||||||
|
if fe.filtered(key, marshaler) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
fe.keyPrefix += key + ">"
|
fe.keyPrefix += key + ">"
|
||||||
return fe.wrapped.AddObject(key, logObjectMarshalerWrapper{
|
return fe.wrapped.AddObject(key, logObjectMarshalerWrapper{
|
||||||
enc: fe,
|
enc: fe,
|
||||||
|
|
Loading…
Reference in a new issue