forked from TrueCloudLab/frostfs-node
[#158] metabase: Add logger to DB configuration
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
60e4b5ddff
commit
36d5af812e
2 changed files with 15 additions and 1 deletions
|
@ -370,6 +370,7 @@ func initLocalStorage(c *cfg) {
|
||||||
|
|
||||||
c.cfgObject.metastorage = meta.NewDB(
|
c.cfgObject.metastorage = meta.NewDB(
|
||||||
meta.FromBoltDB(boltDB),
|
meta.FromBoltDB(boltDB),
|
||||||
|
meta.WithLogger(c.log),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,9 @@ package meta
|
||||||
import (
|
import (
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/object"
|
"github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||||
v2object "github.com/nspcc-dev/neofs-api-go/v2/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.etcd.io/bbolt"
|
||||||
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DB represents local metabase of storage node.
|
// DB represents local metabase of storage node.
|
||||||
|
@ -20,10 +22,14 @@ type Option func(*cfg)
|
||||||
|
|
||||||
type cfg struct {
|
type cfg struct {
|
||||||
boltDB *bbolt.DB
|
boltDB *bbolt.DB
|
||||||
|
|
||||||
|
log *logger.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
func defaultCfg() *cfg {
|
func defaultCfg() *cfg {
|
||||||
return &cfg{}
|
return &cfg{
|
||||||
|
log: zap.L(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDB creates, initializes and returns DB instance.
|
// NewDB creates, initializes and returns DB instance.
|
||||||
|
@ -70,3 +76,10 @@ func FromBoltDB(db *bbolt.DB) Option {
|
||||||
c.boltDB = db
|
c.boltDB = db
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithLogger returns option to set logger of DB.
|
||||||
|
func WithLogger(l *logger.Logger) Option {
|
||||||
|
return func(c *cfg) {
|
||||||
|
c.log = l
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue