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

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-11-23 14:23:58 +03:00 committed by Alex Vanin
parent cf2dc37a42
commit af6484e3b1
2 changed files with 12 additions and 0 deletions

View file

@ -303,6 +303,7 @@ func initObjectService(c *cfg) {
rangesvc.WithLocalAddressSource(c), rangesvc.WithLocalAddressSource(c),
rangesvc.WithWorkerPool(c.cfgObject.pool.rng), rangesvc.WithWorkerPool(c.cfgObject.pool.rng),
rangesvc.WithHeadService(sHead), rangesvc.WithHeadService(sHead),
rangesvc.WithLogger(c.log),
) )
sRangeV2 := rangesvcV2.NewService( sRangeV2 := rangesvcV2.NewService(

View file

@ -13,7 +13,9 @@ import (
headsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/head" headsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/head"
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 {
@ -38,11 +40,14 @@ type cfg struct {
headSvc *headsvc.Service headSvc *headsvc.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(),
} }
} }
@ -173,3 +178,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
}
}