MCPcopy
hub / github.com/rs/zerolog / TestUpdateContextOnNopLogger

Function TestUpdateContextOnNopLogger

log_test.go:1282–1297  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1280}
1281
1282func TestUpdateContextOnNopLogger(t *testing.T) {
1283 // Nop() creates a new disabled logger that is a different pointer than
1284 // the package-level disabledLogger. UpdateContext should still treat it
1285 // as disabled and skip the update function. See issue #643.
1286 log := Nop()
1287
1288 called := false
1289 log.UpdateContext(func(c Context) Context {
1290 called = true
1291 return c.Str("foo", "bar")
1292 })
1293
1294 if called {
1295 t.Error("UpdateContext should not call update func on a Nop logger")
1296 }
1297}
1298
1299func TestUpdateContextOnZeroValueLogger(t *testing.T) {
1300 // A zero-value Logger has a nil writer and should be treated as

Callers

nothing calls this directly

Calls 4

NopFunction · 0.85
UpdateContextMethod · 0.80
StrMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected