()
| 342 | } |
| 343 | |
| 344 | func 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 | |
| 362 | func ExampleDict() { |
| 363 | logger := zap.NewExample() |
nothing calls this directly
no test coverage detected