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

Function ExampleWrapCore_wrap

example_test.go:344–360  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

342}
343
344func ExampleWrapCore_wrap() {
345 // Wrapping a Logger's core can extend its functionality. As a trivial
346 // example, it can double-write all logs.
347 doubled := zap.WrapCore(func(c zapcore.Core) zapcore.Core {
348 return zapcore.NewTee(c, c)
349 })
350
351 logger := zap.NewExample()
352 defer logger.Sync()
353
354 logger.Info("single")
355 logger.WithOptions(doubled).Info("doubled")
356 // Output:
357 // {"level":"info","msg":"single"}
358 // {"level":"info","msg":"doubled"}
359 // {"level":"info","msg":"doubled"}
360}
361
362func ExampleDict() {
363 logger := zap.NewExample()

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected