chore: introduce silent test logger config

This commit is contained in:
Patryk Osmaczko 2024-02-26 15:51:37 +01:00 committed by osmaczko
parent fca6cafc44
commit fcd8e62b40
3 changed files with 21 additions and 2 deletions

View File

@ -12,8 +12,7 @@ var registerOnce sync.Once
// MustCreateTestLogger returns a logger based on the passed flags.
func MustCreateTestLogger() *zap.Logger {
cfg := zap.NewDevelopmentConfig()
return MustCreateTestLoggerWithConfig(cfg)
return MustCreateTestLoggerWithConfig(loggerConfig())
}
func MustCreateTestLoggerWithConfig(cfg zap.Config) *zap.Logger {

View File

@ -0,0 +1,9 @@
//go:build !test_silent
package tt
import "go.uber.org/zap"
func loggerConfig() zap.Config {
return zap.NewDevelopmentConfig()
}

View File

@ -0,0 +1,11 @@
//go:build test_silent
package tt
import "go.uber.org/zap"
func loggerConfig() zap.Config {
config := zap.NewProductionConfig()
config.Level = zap.NewAtomicLevelAt(zap.WarnLevel)
return config
}