From cb46e4b15404816295556d4a31a378e9ef76632b Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Mon, 23 Nov 2020 14:24:51 +0300 Subject: [PATCH] [#195] object/rangehash: Add option to set logger Signed-off-by: Leonard Lyubich --- cmd/neofs-node/object.go | 1 + pkg/services/object/rangehash/service.go | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/cmd/neofs-node/object.go b/cmd/neofs-node/object.go index b6b98c5c9..60017c9a1 100644 --- a/cmd/neofs-node/object.go +++ b/cmd/neofs-node/object.go @@ -328,6 +328,7 @@ func initObjectService(c *cfg) { rangehashsvc.WithHeadService(sHead), rangehashsvc.WithRangeService(sRange), rangehashsvc.WithWorkerPool(c.cfgObject.pool.rngHash), + rangehashsvc.WithLogger(c.log), ) sRangeHashV2 := rangehashsvcV2.NewService( diff --git a/pkg/services/object/rangehash/service.go b/pkg/services/object/rangehash/service.go index a40dbb8eb..3268ab13c 100644 --- a/pkg/services/object/rangehash/service.go +++ b/pkg/services/object/rangehash/service.go @@ -17,7 +17,9 @@ import ( rangesvc "github.com/nspcc-dev/neofs-node/pkg/services/object/range" 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/logger" "github.com/pkg/errors" + "go.uber.org/zap" ) type Service struct { @@ -44,11 +46,14 @@ type cfg struct { rangeSvc *rangesvc.Service clientCache *cache.ClientCache + + log *logger.Logger } func defaultCfg() *cfg { return &cfg{ workerPool: new(util.SyncWorkerPool), + log: zap.L(), } } @@ -273,3 +278,9 @@ func WithClientCache(v *cache.ClientCache) Option { c.clientCache = v } } + +func WithLogger(l *logger.Logger) Option { + return func(c *cfg) { + c.log = l + } +}