-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make zaptest.NewTestingWriter public (#1399)
**Add more flexibility in configuring zap logger for tests.** The default `zapcore.Core`, which is created in `zaptest.NewLogger()` may not be suitable for all use-cases. ``` func NewLogger(t TestingT, opts ...LoggerOption) *zap.Logger { ... return zap.New( zapcore.NewCore( zapcore.NewConsoleEncoder(zap.NewDevelopmentEncoderConfig()), writer, cfg.Level, ), zapOptions..., ) ``` E.g., we may need custom encoder or encoder config. This PR allows us to do such customization: ``` writer := zaptest.NewTestingWriter(t) core := zapcore.NewCore(encoder, writer, level) logger := zap.New(core, zap.AddCaller()) ```
- Loading branch information
Showing
2 changed files
with
28 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters