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

Function ExampleWrapCore_replace

example_test.go:326–342  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

324}
325
326func ExampleWrapCore_replace() {
327 // Replacing a Logger's core can alter fundamental behaviors.
328 // For example, it can convert a Logger to a no-op.
329 nop := zap.WrapCore(func(zapcore.Core) zapcore.Core {
330 return zapcore.NewNopCore()
331 })
332
333 logger := zap.NewExample()
334 defer logger.Sync()
335
336 logger.Info("working")
337 logger.WithOptions(nop).Info("no-op")
338 logger.Info("original logger still works")
339 // Output:
340 // {"level":"info","msg":"working"}
341 // {"level":"info","msg":"original logger still works"}
342}
343
344func ExampleWrapCore_wrap() {
345 // Wrapping a Logger's core can extend its functionality. As a trivial

Callers

nothing calls this directly

Calls 6

WrapCoreFunction · 0.92
NewNopCoreFunction · 0.92
NewExampleFunction · 0.92
SyncMethod · 0.65
InfoMethod · 0.45
WithOptionsMethod · 0.45

Tested by

no test coverage detected