From 9fbfc0b5e4130ab0cc6f5c58d25f93c196b21927 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Mon, 23 Nov 2020 14:20:59 +0300 Subject: [PATCH] [#195] object/head: Add option to set logger Signed-off-by: Leonard Lyubich --- cmd/neofs-node/object.go | 1 + pkg/services/object/head/service.go | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/cmd/neofs-node/object.go b/cmd/neofs-node/object.go index d5c1d3375..2c4cf8986 100644 --- a/cmd/neofs-node/object.go +++ b/cmd/neofs-node/object.go @@ -286,6 +286,7 @@ func initObjectService(c *cfg) { headsvc.WithLocalAddressSource(c), headsvc.WithRightChildSearcher(searchsvc.NewRightChildSearcher(sSearch)), headsvc.WithWorkerPool(c.cfgObject.pool.head), + headsvc.WithLogger(c.log), ) sHeadV2 := headsvcV2.NewService( diff --git a/pkg/services/object/head/service.go b/pkg/services/object/head/service.go index 1c86aaa9e..02e38ade1 100644 --- a/pkg/services/object/head/service.go +++ b/pkg/services/object/head/service.go @@ -11,7 +11,9 @@ import ( "github.com/nspcc-dev/neofs-node/pkg/network/cache" 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 RelationSearcher interface { @@ -38,6 +40,8 @@ type cfg struct { localHeader localHeader remoteHeader RemoteHeader + + log *logger.Logger } var ErrNotFound = errors.New("object header not found") @@ -45,6 +49,7 @@ var ErrNotFound = errors.New("object header not found") func defaultCfg() *cfg { return &cfg{ workerPool: new(util.SyncWorkerPool), + log: zap.L(), } } @@ -141,3 +146,9 @@ func WithClientCache(v *cache.ClientCache) Option { c.remoteHeader.clientCache = v } } + +func WithLogger(l *logger.Logger) Option { + return func(c *cfg) { + c.log = l + } +}