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"
|
||||
|
||||
"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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue