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: Little fix for filtering object fields
Matthew Holt committed
Jan 1, 2020 at 10:26 UTC
8c7c2e4af2e4e7ad842b959e2100855f6edadd68
1 file changed
+8
modules/logging/filterencoder.go
+8
@@ -39,6 +39,11 @@ type FilterEncoder struct {
39
40
// A map of field names to their filters. Note that this
41
// is not a module map; the keys are field names.
42
+ //
43
+ // Nested fields can be referenced by representing a
44
+ // layer of nesting with `>`. In other words, for an
45
+ // object like `{"a":{"b":0}}`, the inner field can
46
+ // be referenced as `a>b`.
47
FieldsRaw map[string]json.RawMessage `json:"fields,omitempty" caddy:"namespace=caddy.logging.encoders.filter inline_key=filter"`
48
49
wrapped zapcore.Encoder
@@ -96,6 +101,9 @@ func (fe FilterEncoder) AddArray(key string, marshaler zapcore.ArrayMarshaler) e
101
102
// AddObject is part of the zapcore.ObjectEncoder interface.
103
func (fe FilterEncoder) AddObject(key string, marshaler zapcore.ObjectMarshaler) error {
104
+ if fe.filtered(key, marshaler) {
105
+ return nil
106
+ }
107
fe.keyPrefix += key + ">"
108
return fe.wrapped.AddObject(key, logObjectMarshalerWrapper{
109
enc: fe,