[#195] object/rangehash: 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:24:51 +03:00 committed by Alex Vanin
parent af6484e3b1
commit cb46e4b154
2 changed files with 12 additions and 0 deletions

View File

@ -328,6 +328,7 @@ func initObjectService(c *cfg) {
rangehashsvc.WithHeadService(sHead), rangehashsvc.WithHeadService(sHead),
rangehashsvc.WithRangeService(sRange), rangehashsvc.WithRangeService(sRange),
rangehashsvc.WithWorkerPool(c.cfgObject.pool.rngHash), rangehashsvc.WithWorkerPool(c.cfgObject.pool.rngHash),
rangehashsvc.WithLogger(c.log),
) )
sRangeHashV2 := rangehashsvcV2.NewService( sRangeHashV2 := rangehashsvcV2.NewService(

View File

@ -17,7 +17,9 @@ import (
rangesvc "github.com/nspcc-dev/neofs-node/pkg/services/object/range" rangesvc "github.com/nspcc-dev/neofs-node/pkg/services/object/range"
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 Service struct { type Service struct {
@ -44,11 +46,14 @@ type cfg struct {
rangeSvc *rangesvc.Service rangeSvc *rangesvc.Service
clientCache *cache.ClientCache clientCache *cache.ClientCache
log *logger.Logger
} }
func defaultCfg() *cfg { func defaultCfg() *cfg {
return &cfg{ return &cfg{
workerPool: new(util.SyncWorkerPool), workerPool: new(util.SyncWorkerPool),
log: zap.L(),
} }
} }
@ -273,3 +278,9 @@ func WithClientCache(v *cache.ClientCache) Option {
c.clientCache = v c.clientCache = v
} }
} }
func WithLogger(l *logger.Logger) Option {
return func(c *cfg) {
c.log = l
}
}