MCPcopy
hub / github.com/uber-go/zap / TestNoEncodeLevelSupplied

Function TestNoEncodeLevelSupplied

zapcore/json_encoder_test.go:153–180  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

151}
152
153func TestNoEncodeLevelSupplied(t *testing.T) {
154 enc := zapcore.NewJSONEncoder(zapcore.EncoderConfig{
155 MessageKey: "M",
156 LevelKey: "L",
157 TimeKey: "T",
158 NameKey: "N",
159 CallerKey: "C",
160 FunctionKey: "F",
161 StacktraceKey: "S",
162 EncodeTime: zapcore.ISO8601TimeEncoder,
163 EncodeDuration: zapcore.SecondsDurationEncoder,
164 EncodeCaller: zapcore.ShortCallerEncoder,
165 })
166
167 ent := zapcore.Entry{
168 Level: zapcore.InfoLevel,
169 Time: time.Date(2018, 6, 19, 16, 33, 42, 99, time.UTC),
170 LoggerName: "bob",
171 Message: "lob law",
172 }
173
174 fields := []zapcore.Field{
175 zap.Int("answer", 42),
176 }
177
178 _, err := enc.EncodeEntry(ent, fields)
179 assert.NoError(t, err, "Unexpected JSON encoding error.")
180}
181
182func TestJSONEmptyConfig(t *testing.T) {
183 tests := []struct {

Callers

nothing calls this directly

Calls 3

NewJSONEncoderFunction · 0.92
IntFunction · 0.92
EncodeEntryMethod · 0.65

Tested by

no test coverage detected