[#195] object/head: Add option to set logger

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
remotes/KirillovDenis/release/v0.21.1
Leonard Lyubich 2020-11-23 14:20:59 +03:00 committed by Alex Vanin
parent e1e5a590e9
commit 9fbfc0b5e4
2 changed files with 12 additions and 0 deletions

View File

@ -286,6 +286,7 @@ func initObjectService(c *cfg) {
headsvc.WithLocalAddressSource(c), headsvc.WithLocalAddressSource(c),
headsvc.WithRightChildSearcher(searchsvc.NewRightChildSearcher(sSearch)), headsvc.WithRightChildSearcher(searchsvc.NewRightChildSearcher(sSearch)),
headsvc.WithWorkerPool(c.cfgObject.pool.head), headsvc.WithWorkerPool(c.cfgObject.pool.head),
headsvc.WithLogger(c.log),
) )
sHeadV2 := headsvcV2.NewService( sHeadV2 := headsvcV2.NewService(

View File

@ -11,7 +11,9 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/network/cache" "github.com/nspcc-dev/neofs-node/pkg/network/cache"
objutil "github.com/nspcc-dev/neofs-node/pkg/services/object/util" objutil "github.com/nspcc-dev/neofs-node/pkg/services/object/util"
"github.com/nspcc-dev/neofs-node/pkg/util" "github.com/nspcc-dev/neofs-node/pkg/util"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"github.com/pkg/errors" "github.com/pkg/errors"
"go.uber.org/zap"
) )
type RelationSearcher interface { type RelationSearcher interface {
@ -38,6 +40,8 @@ type cfg struct {
localHeader localHeader localHeader localHeader
remoteHeader RemoteHeader remoteHeader RemoteHeader
log *logger.Logger
} }
var ErrNotFound = errors.New("object header not found") var ErrNotFound = errors.New("object header not found")
@ -45,6 +49,7 @@ var ErrNotFound = errors.New("object header not found")
func defaultCfg() *cfg { func defaultCfg() *cfg {
return &cfg{ return &cfg{
workerPool: new(util.SyncWorkerPool), workerPool: new(util.SyncWorkerPool),
log: zap.L(),
} }
} }
@ -141,3 +146,9 @@ func WithClientCache(v *cache.ClientCache) Option {
c.remoteHeader.clientCache = v c.remoteHeader.clientCache = v
} }
} }
func WithLogger(l *logger.Logger) Option {
return func(c *cfg) {
c.log = l
}
}