[#895] test: Use zaptest logger

Previous implementation mixes logs from different tests, now logs
are separeted by test.

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
Dmitrii Stepanov 2024-01-09 12:32:13 +03:00 committed by Evgenii Stratonikov
parent f1b2b8bffa
commit 836818fb75

View file

@ -4,21 +4,16 @@ import (
"testing" "testing"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
"github.com/stretchr/testify/require"
"go.uber.org/zap" "go.uber.org/zap"
"go.uber.org/zap/zapcore" "go.uber.org/zap/zapcore"
"go.uber.org/zap/zaptest"
) )
// NewLogger creates a new logger. // NewLogger creates a new logger.
func NewLogger(t testing.TB) *logger.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 var l logger.Logger
l.Logger = log l.Logger = zaptest.NewLogger(t,
zaptest.Level(zapcore.DebugLevel),
zaptest.WrapOptions(zap.Development(), zap.AddCaller()))
return &l return &l
} }