forked from TrueCloudLab/frostfs-node
[#1770] logger: Refactor Logger
component
Make it store its internal `zap.Logger`'s level. Also, make all the components to accept internal `logger.Logger` instead of `zap.Logger`; it will simplify future refactor. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
4baf00aa21
commit
f037022a7a
83 changed files with 207 additions and 156 deletions
|
@ -11,6 +11,7 @@ import (
|
|||
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/common"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/internal/blobstortest"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/util/logger/test"
|
||||
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
|
||||
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
||||
|
@ -135,7 +136,7 @@ func testFillOrder(t *testing.T, depth uint64) {
|
|||
p, err := os.MkdirTemp("", "*")
|
||||
require.NoError(t, err)
|
||||
b := NewBlobovniczaTree(
|
||||
WithLogger(zaptest.NewLogger(t)),
|
||||
WithLogger(&logger.Logger{Logger: zaptest.NewLogger(t)}),
|
||||
WithObjectSizeLimit(2048),
|
||||
WithBlobovniczaShallowWidth(3),
|
||||
WithBlobovniczaShallowDepth(depth),
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/common"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/internal/blobstortest"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
|
||||
"go.uber.org/zap/zaptest"
|
||||
)
|
||||
|
||||
|
@ -18,7 +19,7 @@ func TestGeneric(t *testing.T) {
|
|||
|
||||
helper := func(t *testing.T, dir string) common.Storage {
|
||||
return NewBlobovniczaTree(
|
||||
WithLogger(zaptest.NewLogger(t)),
|
||||
WithLogger(&logger.Logger{Logger: zaptest.NewLogger(t)}),
|
||||
WithObjectSizeLimit(maxObjectSize),
|
||||
WithBlobovniczaShallowWidth(2),
|
||||
WithBlobovniczaShallowDepth(2),
|
||||
|
@ -51,7 +52,7 @@ func TestControl(t *testing.T) {
|
|||
newTree := func(t *testing.T) common.Storage {
|
||||
dir := filepath.Join(t.Name(), strconv.Itoa(n))
|
||||
return NewBlobovniczaTree(
|
||||
WithLogger(zaptest.NewLogger(t)),
|
||||
WithLogger(&logger.Logger{Logger: zaptest.NewLogger(t)}),
|
||||
WithObjectSizeLimit(maxObjectSize),
|
||||
WithBlobovniczaShallowWidth(2),
|
||||
WithBlobovniczaShallowDepth(2),
|
||||
|
|
|
@ -5,11 +5,12 @@ import (
|
|||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobovnicza"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/compression"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type cfg struct {
|
||||
log *zap.Logger
|
||||
log *logger.Logger
|
||||
perm fs.FileMode
|
||||
readOnly bool
|
||||
rootPath string
|
||||
|
@ -31,7 +32,7 @@ const (
|
|||
|
||||
func initConfig(c *cfg) {
|
||||
*c = cfg{
|
||||
log: zap.L(),
|
||||
log: &logger.Logger{Logger: zap.L()},
|
||||
perm: defaultPerm,
|
||||
openedCacheSize: defaultOpenedCacheSize,
|
||||
blzShallowDepth: defaultBlzShallowDepth,
|
||||
|
@ -39,7 +40,7 @@ func initConfig(c *cfg) {
|
|||
}
|
||||
}
|
||||
|
||||
func WithLogger(l *zap.Logger) Option {
|
||||
func WithLogger(l *logger.Logger) Option {
|
||||
return func(c *cfg) {
|
||||
c.log = l
|
||||
c.blzOpts = append(c.blzOpts, blobovnicza.WithLogger(l))
|
||||
|
|
|
@ -46,7 +46,7 @@ type cfg struct {
|
|||
}
|
||||
|
||||
func initConfig(c *cfg) {
|
||||
c.log = zap.L()
|
||||
c.log = &logger.Logger{Logger: zap.L()}
|
||||
}
|
||||
|
||||
// New creates, initializes and returns new BlobStor instance.
|
||||
|
@ -66,7 +66,7 @@ func New(opts ...Option) *BlobStor {
|
|||
}
|
||||
|
||||
// SetLogger sets logger. It is used after the shard ID was generated to use it in logs.
|
||||
func (b *BlobStor) SetLogger(l *zap.Logger) {
|
||||
func (b *BlobStor) SetLogger(l *logger.Logger) {
|
||||
b.log = l
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ func WithStorages(st []SubStorage) Option {
|
|||
// WithLogger returns option to specify BlobStor's logger.
|
||||
func WithLogger(l *logger.Logger) Option {
|
||||
return func(c *cfg) {
|
||||
c.log = l.With(zap.String("component", "BlobStor"))
|
||||
c.log = &logger.Logger{Logger: l.With(zap.String("component", "BlobStor"))}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue