I have a Zap logger that is generated from a custom Config (i.e. config.Build()). I would like to test the logger by calling, for example, logger.Info() in the test method and assert the result to see if it is according to the config set. How can I achieve this?
EDIT: Adding a code example in the following
func GetLogger() *zap.Logger{
config := &zap.Config{
Encoding: "json",
Level: zap.NewAtomicLevelAt(zapcore.InfoLevel),
OutputPaths: []string{"stdout"},
ErrorOutputPaths: []string{"stdout"},
EncoderConfig: zapcore.EncoderConfig{
MessageKey: "@m",
LevelKey: "@l",
EncodeLevel: zapcore.CapitalLevelEncoder,
TimeKey: "@t",
EncodeTime: zapcore.EpochMillisTimeEncoder,
CallerKey: "@c",
EncodeCaller: zapcore.ShortCallerEncoder,
StacktraceKey: "@x",
},
}
return config.Build()
}