forked from TrueCloudLab/frostfs-node
[#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:
parent
f1b2b8bffa
commit
836818fb75
1 changed files with 4 additions and 9 deletions
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue