From 836818fb751f79ac129121d0eeea44de0193efc4 Mon Sep 17 00:00:00 2001 From: Dmitrii Stepanov Date: Tue, 9 Jan 2024 12:32:13 +0300 Subject: [PATCH] [#895] test: Use zaptest logger Previous implementation mixes logs from different tests, now logs are separeted by test. Signed-off-by: Dmitrii Stepanov --- pkg/util/logger/test/logger.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/pkg/util/logger/test/logger.go b/pkg/util/logger/test/logger.go index dd07e617..f93756d1 100644 --- a/pkg/util/logger/test/logger.go +++ b/pkg/util/logger/test/logger.go @@ -4,21 +4,16 @@ import ( "testing" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger" - "github.com/stretchr/testify/require" "go.uber.org/zap" "go.uber.org/zap/zapcore" + "go.uber.org/zap/zaptest" ) // NewLogger creates a new logger. func NewLogger(t testing.TB) *logger.Logger { - cfg := zap.NewDevelopmentConfig() - cfg.EncoderConfig.EncodeLevel = zapcore.CapitalColorLevelEncoder - - log, err := cfg.Build() - require.NoError(t, err, "could not prepare logger") - var l logger.Logger - l.Logger = log - + l.Logger = zaptest.NewLogger(t, + zaptest.Level(zapcore.DebugLevel), + zaptest.WrapOptions(zap.Development(), zap.AddCaller())) return &l }