@marcel91200 / caddy Mirror · read-only
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 11, 01:00 UTC

master
go 114 lines 4.27 KB
Raw
1 // Copyright 2015 Matthew Holt and The Caddy Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 package logging
16
17 import (
18 "time"
19
20 "go.uber.org/zap/buffer"
21 "go.uber.org/zap/zapcore"
22 )
23
24 // nopEncoder is a zapcore.Encoder that does nothing.
25 type nopEncoder struct{}
26
27 // AddArray is part of the zapcore.ObjectEncoder interface.
28 // Array elements do not get filtered.
29 func (nopEncoder) AddArray(key string, marshaler zapcore.ArrayMarshaler) error { return nil }
30
31 // AddObject is part of the zapcore.ObjectEncoder interface.
32 func (nopEncoder) AddObject(key string, marshaler zapcore.ObjectMarshaler) error { return nil }
33
34 // AddBinary is part of the zapcore.ObjectEncoder interface.
35 func (nopEncoder) AddBinary(key string, value []byte) {}
36
37 // AddByteString is part of the zapcore.ObjectEncoder interface.
38 func (nopEncoder) AddByteString(key string, value []byte) {}
39
40 // AddBool is part of the zapcore.ObjectEncoder interface.
41 func (nopEncoder) AddBool(key string, value bool) {}
42
43 // AddComplex128 is part of the zapcore.ObjectEncoder interface.
44 func (nopEncoder) AddComplex128(key string, value complex128) {}
45
46 // AddComplex64 is part of the zapcore.ObjectEncoder interface.
47 func (nopEncoder) AddComplex64(key string, value complex64) {}
48
49 // AddDuration is part of the zapcore.ObjectEncoder interface.
50 func (nopEncoder) AddDuration(key string, value time.Duration) {}
51
52 // AddFloat64 is part of the zapcore.ObjectEncoder interface.
53 func (nopEncoder) AddFloat64(key string, value float64) {}
54
55 // AddFloat32 is part of the zapcore.ObjectEncoder interface.
56 func (nopEncoder) AddFloat32(key string, value float32) {}
57
58 // AddInt is part of the zapcore.ObjectEncoder interface.
59 func (nopEncoder) AddInt(key string, value int) {}
60
61 // AddInt64 is part of the zapcore.ObjectEncoder interface.
62 func (nopEncoder) AddInt64(key string, value int64) {}
63
64 // AddInt32 is part of the zapcore.ObjectEncoder interface.
65 func (nopEncoder) AddInt32(key string, value int32) {}
66
67 // AddInt16 is part of the zapcore.ObjectEncoder interface.
68 func (nopEncoder) AddInt16(key string, value int16) {}
69
70 // AddInt8 is part of the zapcore.ObjectEncoder interface.
71 func (nopEncoder) AddInt8(key string, value int8) {}
72
73 // AddString is part of the zapcore.ObjectEncoder interface.
74 func (nopEncoder) AddString(key, value string) {}
75
76 // AddTime is part of the zapcore.ObjectEncoder interface.
77 func (nopEncoder) AddTime(key string, value time.Time) {}
78
79 // AddUint is part of the zapcore.ObjectEncoder interface.
80 func (nopEncoder) AddUint(key string, value uint) {}
81
82 // AddUint64 is part of the zapcore.ObjectEncoder interface.
83 func (nopEncoder) AddUint64(key string, value uint64) {}
84
85 // AddUint32 is part of the zapcore.ObjectEncoder interface.
86 func (nopEncoder) AddUint32(key string, value uint32) {}
87
88 // AddUint16 is part of the zapcore.ObjectEncoder interface.
89 func (nopEncoder) AddUint16(key string, value uint16) {}
90
91 // AddUint8 is part of the zapcore.ObjectEncoder interface.
92 func (nopEncoder) AddUint8(key string, value uint8) {}
93
94 // AddUintptr is part of the zapcore.ObjectEncoder interface.
95 func (nopEncoder) AddUintptr(key string, value uintptr) {}
96
97 // AddReflected is part of the zapcore.ObjectEncoder interface.
98 func (nopEncoder) AddReflected(key string, value any) error { return nil }
99
100 // OpenNamespace is part of the zapcore.ObjectEncoder interface.
101 func (nopEncoder) OpenNamespace(key string) {}
102
103 // Clone is part of the zapcore.ObjectEncoder interface.
104 // We don't use it as of Oct 2019 (v2 beta 7), I'm not
105 // really sure what it'd be useful for in our case.
106 func (ne nopEncoder) Clone() zapcore.Encoder { return ne }
107
108 // EncodeEntry partially implements the zapcore.Encoder interface.
109 func (nopEncoder) EncodeEntry(ent zapcore.Entry, fields []zapcore.Field) (*buffer.Buffer, error) {
110 return bufferpool.Get(), nil
111 }
112
113 // Interface guard
114 var _ zapcore.Encoder = (*nopEncoder)(nil)