diff options
author | Matthew Holt <mholt@users.noreply.github.com> | 2020-01-01 10:26:37 -0700 |
---|---|---|
committer | Matthew Holt <mholt@users.noreply.github.com> | 2020-01-01 10:26:37 -0700 |
commit | 8c7c2e4af2e4e7ad842b959e2100855f6edadd68 (patch) | |
tree | 1d1adfa81a874ddce7ed4022b8b1b971e78f9046 /modules/logging | |
parent | 3d9f8eac08e172d99eafb396f161263fd444c073 (diff) |
logging: Little fix for filtering object fields
Diffstat (limited to 'modules/logging')
-rw-r--r-- | modules/logging/filterencoder.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/modules/logging/filterencoder.go b/modules/logging/filterencoder.go index 6680019..36823fa 100644 --- a/modules/logging/filterencoder.go +++ b/modules/logging/filterencoder.go @@ -39,6 +39,11 @@ type FilterEncoder struct { // A map of field names to their filters. Note that this // 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"` 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. func (fe FilterEncoder) AddObject(key string, marshaler zapcore.ObjectMarshaler) error { + if fe.filtered(key, marshaler) { + return nil + } fe.keyPrefix += key + ">" return fe.wrapped.AddObject(key, logObjectMarshalerWrapper{ enc: fe, |