From 36d5af812ea8219df5875002a009df1e1ce111a2 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Mon, 9 Nov 2020 13:22:36 +0300 Subject: [PATCH] [#158] metabase: Add logger to DB configuration Signed-off-by: Leonard Lyubich --- cmd/neofs-node/config.go | 1 + pkg/local_object_storage/metabase/db.go | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/cmd/neofs-node/config.go b/cmd/neofs-node/config.go index fc9554661..3f0ca72a1 100644 --- a/cmd/neofs-node/config.go +++ b/cmd/neofs-node/config.go @@ -370,6 +370,7 @@ func initLocalStorage(c *cfg) { c.cfgObject.metastorage = meta.NewDB( meta.FromBoltDB(boltDB), + meta.WithLogger(c.log), ) } diff --git a/pkg/local_object_storage/metabase/db.go b/pkg/local_object_storage/metabase/db.go index 56780a595..46f73587c 100644 --- a/pkg/local_object_storage/metabase/db.go +++ b/pkg/local_object_storage/metabase/db.go @@ -3,7 +3,9 @@ package meta import ( "github.com/nspcc-dev/neofs-api-go/pkg/object" v2object "github.com/nspcc-dev/neofs-api-go/v2/object" + "github.com/nspcc-dev/neofs-node/pkg/util/logger" "go.etcd.io/bbolt" + "go.uber.org/zap" ) // DB represents local metabase of storage node. @@ -20,10 +22,14 @@ type Option func(*cfg) type cfg struct { boltDB *bbolt.DB + + log *logger.Logger } func defaultCfg() *cfg { - return &cfg{} + return &cfg{ + log: zap.L(), + } } // NewDB creates, initializes and returns DB instance. @@ -70,3 +76,10 @@ func FromBoltDB(db *bbolt.DB) Option { c.boltDB = db } } + +// WithLogger returns option to set logger of DB. +func WithLogger(l *logger.Logger) Option { + return func(c *cfg) { + c.log = l + } +}