frostfs-node/pkg/util/logger/test/logger.go
Evgenii Stratonikov 02b03d9c4f [#638] logger: Remove sampling from test loggers
Losing logs is always a bad idea, especially when we debug tests.

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
2023-08-23 11:21:05 +00:00

29 lines
597 B
Go

package test
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"
)
// NewLogger creates a new logger.
//
// If debug, development logger is created.
func NewLogger(t testing.TB, debug bool) *logger.Logger {
var l logger.Logger
l.Logger = zap.L()
if debug {
cfg := zap.NewDevelopmentConfig()
cfg.EncoderConfig.EncodeLevel = zapcore.CapitalColorLevelEncoder
log, err := cfg.Build()
require.NoError(t, err, "could not prepare logger")
l.Logger = log
}
return &l
}