2020-07-10 14:17:51 +00:00
|
|
|
package test
|
|
|
|
|
|
|
|
import (
|
2020-07-24 13:54:03 +00:00
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
|
2020-07-10 14:17:51 +00:00
|
|
|
"go.uber.org/zap"
|
|
|
|
"go.uber.org/zap/zapcore"
|
|
|
|
)
|
|
|
|
|
|
|
|
const sampling = 1000
|
|
|
|
|
2020-07-24 13:54:03 +00:00
|
|
|
// NewLogger creates a new logger.
|
|
|
|
//
|
|
|
|
// If debug, development logger is created.
|
|
|
|
func NewLogger(debug bool) *logger.Logger {
|
2020-07-10 14:17:51 +00:00
|
|
|
if debug {
|
|
|
|
cfg := zap.NewDevelopmentConfig()
|
|
|
|
cfg.Sampling = &zap.SamplingConfig{
|
|
|
|
Initial: sampling,
|
|
|
|
Thereafter: sampling,
|
|
|
|
}
|
|
|
|
|
|
|
|
cfg.EncoderConfig.EncodeLevel = zapcore.CapitalColorLevelEncoder
|
|
|
|
|
|
|
|
log, err := cfg.Build()
|
|
|
|
if err != nil {
|
|
|
|
panic("could not prepare logger: " + err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
return log
|
|
|
|
}
|
|
|
|
|
|
|
|
return zap.L()
|
|
|
|
}
|