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

Function TestSugaredLoggerLevel

sugar_test.go:241–268  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

239}
240
241func TestSugaredLoggerLevel(t *testing.T) {
242 levels := []zapcore.Level{
243 DebugLevel,
244 InfoLevel,
245 WarnLevel,
246 ErrorLevel,
247 DPanicLevel,
248 PanicLevel,
249 FatalLevel,
250 }
251
252 for _, lvl := range levels {
253 lvl := lvl
254 t.Run(lvl.String(), func(t *testing.T) {
255 t.Parallel()
256
257 core, _ := observer.New(lvl)
258 log := New(core).Sugar()
259 assert.Equal(t, lvl, log.Level())
260 })
261 }
262
263 t.Run("Nop", func(t *testing.T) {
264 t.Parallel()
265
266 assert.Equal(t, zapcore.InvalidLevel, NewNop().Sugar().Level())
267 })
268}
269
270func TestSugarFieldsInvalidPairs(t *testing.T) {
271 withSugar(t, DebugLevel, nil, func(logger *SugaredLogger, logs *observer.ObservedLogs) {

Callers

nothing calls this directly

Calls 6

NewFunction · 0.92
NewNopFunction · 0.85
SugarMethod · 0.80
NewFunction · 0.70
LevelMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected