[#1770] logger: Refactor Logger component

Make it store its internal `zap.Logger`'s level. Also, make all the
components to accept internal `logger.Logger` instead of `zap.Logger`; it
will simplify future refactor.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2022-09-28 10:41:01 +03:00 committed by Pavel Karpy
parent 4baf00aa21
commit f037022a7a
83 changed files with 207 additions and 156 deletions

View file

@ -289,7 +289,7 @@ type internals struct {
appCfg *config.Config appCfg *config.Config
log *zap.Logger log *logger.Logger
wg *sync.WaitGroup wg *sync.WaitGroup
workers []worker workers []worker

View file

@ -92,7 +92,7 @@ func serveGRPC(c *cfg) {
} }
func stopGRPC(name string, s *grpc.Server, l *logger.Logger) { func stopGRPC(name string, s *grpc.Server, l *logger.Logger) {
l = l.With(zap.String("name", name)) l = &logger.Logger{Logger: l.With(zap.String("name", name))}
l.Info("stopping gRPC server...") l.Info("stopping gRPC server...")

View file

@ -10,6 +10,7 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/morph/event/netmap" "github.com/nspcc-dev/neofs-node/pkg/morph/event/netmap"
"github.com/nspcc-dev/neofs-node/pkg/services/notificator" "github.com/nspcc-dev/neofs-node/pkg/services/notificator"
"github.com/nspcc-dev/neofs-node/pkg/services/notificator/nats" "github.com/nspcc-dev/neofs-node/pkg/services/notificator/nats"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object" objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id" oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
"go.uber.org/zap" "go.uber.org/zap"
@ -17,7 +18,7 @@ import (
type notificationSource struct { type notificationSource struct {
e *engine.StorageEngine e *engine.StorageEngine
l *zap.Logger l *logger.Logger
defaultTopic string defaultTopic string
} }
@ -92,7 +93,7 @@ func (n *notificationSource) processAddress(
} }
type notificationWriter struct { type notificationWriter struct {
l *zap.Logger l *logger.Logger
w *nats.Writer w *nats.Writer
} }

View file

@ -60,8 +60,8 @@ func initReputationService(c *cfg) {
Storage: consumerStorage, Storage: consumerStorage,
} }
localTrustLogger := c.log.With(zap.String("trust_type", "local")) localTrustLogger := &logger.Logger{Logger: c.log.With(zap.String("trust_type", "local"))}
intermediateTrustLogger := c.log.With(zap.String("trust_type", "intermediate")) intermediateTrustLogger := &logger.Logger{Logger: c.log.With(zap.String("trust_type", "intermediate"))}
localTrustStorage := &localreputation.TrustStorage{ localTrustStorage := &localreputation.TrustStorage{
Log: localTrustLogger, Log: localTrustLogger,

View file

@ -133,7 +133,7 @@ type FinalWriterOption func(*finalWriterOptions)
func defaultFinalWriterOptionsOpts() *finalWriterOptions { func defaultFinalWriterOptionsOpts() *finalWriterOptions {
return &finalWriterOptions{ return &finalWriterOptions{
log: zap.L(), log: &logger.Logger{Logger: zap.L()},
} }
} }

View file

@ -10,6 +10,7 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/morph/client/container" "github.com/nspcc-dev/neofs-node/pkg/morph/client/container"
"github.com/nspcc-dev/neofs-node/pkg/morph/event" "github.com/nspcc-dev/neofs-node/pkg/morph/event"
"github.com/nspcc-dev/neofs-node/pkg/morph/timer" "github.com/nspcc-dev/neofs-node/pkg/morph/timer"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -28,7 +29,7 @@ type (
newEpochHandler func() newEpochHandler func()
epochTimerArgs struct { epochTimerArgs struct {
l *zap.Logger l *logger.Logger
newEpochHandlers []newEpochHandler newEpochHandlers []newEpochHandler

View file

@ -47,6 +47,7 @@ import (
reputationcommon "github.com/nspcc-dev/neofs-node/pkg/services/reputation/common" reputationcommon "github.com/nspcc-dev/neofs-node/pkg/services/reputation/common"
util2 "github.com/nspcc-dev/neofs-node/pkg/util" util2 "github.com/nspcc-dev/neofs-node/pkg/util"
utilConfig "github.com/nspcc-dev/neofs-node/pkg/util/config" utilConfig "github.com/nspcc-dev/neofs-node/pkg/util/config"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"github.com/nspcc-dev/neofs-node/pkg/util/precision" "github.com/nspcc-dev/neofs-node/pkg/util/precision"
"github.com/nspcc-dev/neofs-node/pkg/util/state" "github.com/nspcc-dev/neofs-node/pkg/util/state"
"github.com/panjf2000/ants/v2" "github.com/panjf2000/ants/v2"
@ -60,7 +61,7 @@ type (
// Server is the inner ring application structure, that contains all event // Server is the inner ring application structure, that contains all event
// processors, shared variables and event handlers. // processors, shared variables and event handlers.
Server struct { Server struct {
log *zap.Logger log *logger.Logger
// event producers // event producers
morphListener event.Listener morphListener event.Listener
@ -128,7 +129,7 @@ type (
} }
chainParams struct { chainParams struct {
log *zap.Logger log *logger.Logger
cfg *viper.Viper cfg *viper.Viper
key *keys.PrivateKey key *keys.PrivateKey
name string name string
@ -316,7 +317,7 @@ func (s *Server) registerStarter(f func() error) {
} }
// New creates instance of inner ring sever structure. // New creates instance of inner ring sever structure.
func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper, errChan chan<- error) (*Server, error) { func New(ctx context.Context, log *logger.Logger, cfg *viper.Viper, errChan chan<- error) (*Server, error) {
var err error var err error
server := &Server{log: log} server := &Server{log: log}
@ -956,7 +957,7 @@ func createListener(ctx context.Context, cli *client.Client, p *chainParams) (ev
} }
listener, err := event.NewListener(event.ListenerParams{ listener, err := event.NewListener(event.ListenerParams{
Logger: p.log.With(zap.String("chain", p.name)), Logger: &logger.Logger{Logger: p.log.With(zap.String("chain", p.name))},
Subscriber: sub, Subscriber: sub,
WorkerPoolCapacity: listenerPoolCap, WorkerPoolCapacity: listenerPoolCap,
}) })

View file

@ -8,6 +8,7 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/client"
nmClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap" nmClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap"
"github.com/nspcc-dev/neofs-node/pkg/morph/event" "github.com/nspcc-dev/neofs-node/pkg/morph/event"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"github.com/panjf2000/ants/v2" "github.com/panjf2000/ants/v2"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -32,7 +33,7 @@ type (
// Processor of events produced for alphabet contracts in the sidechain. // Processor of events produced for alphabet contracts in the sidechain.
Processor struct { Processor struct {
log *zap.Logger log *logger.Logger
pool *ants.Pool pool *ants.Pool
alphabetContracts Contracts alphabetContracts Contracts
netmapClient *nmClient.Client netmapClient *nmClient.Client
@ -43,7 +44,7 @@ type (
// Params of the processor constructor. // Params of the processor constructor.
Params struct { Params struct {
Log *zap.Logger Log *logger.Logger
PoolSize int PoolSize int
AlphabetContracts Contracts AlphabetContracts Contracts
NetmapClient *nmClient.Client NetmapClient *nmClient.Client

View file

@ -12,8 +12,8 @@ import (
nmClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap" nmClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap"
"github.com/nspcc-dev/neofs-node/pkg/morph/event" "github.com/nspcc-dev/neofs-node/pkg/morph/event"
"github.com/nspcc-dev/neofs-node/pkg/services/audit" "github.com/nspcc-dev/neofs-node/pkg/services/audit"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"github.com/panjf2000/ants/v2" "github.com/panjf2000/ants/v2"
"go.uber.org/zap"
) )
type ( type (
@ -40,7 +40,7 @@ type (
// Processor of events related to data audit. // Processor of events related to data audit.
Processor struct { Processor struct {
log *zap.Logger log *logger.Logger
pool *ants.Pool pool *ants.Pool
irList Indexer irList Indexer
sgSrc storagegroup.SGSource sgSrc storagegroup.SGSource
@ -57,7 +57,7 @@ type (
// Params of the processor constructor. // Params of the processor constructor.
Params struct { Params struct {
Log *zap.Logger Log *logger.Logger
NetmapClient *nmClient.Client NetmapClient *nmClient.Client
ContainerClient *cntClient.Client ContainerClient *cntClient.Client
IRList Indexer IRList Indexer

View file

@ -8,6 +8,7 @@ import (
neofscontract "github.com/nspcc-dev/neofs-node/pkg/morph/client/neofs" neofscontract "github.com/nspcc-dev/neofs-node/pkg/morph/client/neofs"
"github.com/nspcc-dev/neofs-node/pkg/morph/event" "github.com/nspcc-dev/neofs-node/pkg/morph/event"
balanceEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/balance" balanceEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/balance"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"github.com/panjf2000/ants/v2" "github.com/panjf2000/ants/v2"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -25,7 +26,7 @@ type (
// Processor of events produced by balance contract in the morphchain. // Processor of events produced by balance contract in the morphchain.
Processor struct { Processor struct {
log *zap.Logger log *logger.Logger
pool *ants.Pool pool *ants.Pool
neofsClient *neofscontract.Client neofsClient *neofscontract.Client
balanceSC util.Uint160 balanceSC util.Uint160
@ -35,7 +36,7 @@ type (
// Params of the processor constructor. // Params of the processor constructor.
Params struct { Params struct {
Log *zap.Logger Log *logger.Logger
PoolSize int PoolSize int
NeoFSClient *neofscontract.Client NeoFSClient *neofscontract.Client
BalanceSC util.Uint160 BalanceSC util.Uint160

View file

@ -10,6 +10,7 @@ import (
morphsubnet "github.com/nspcc-dev/neofs-node/pkg/morph/client/subnet" morphsubnet "github.com/nspcc-dev/neofs-node/pkg/morph/client/subnet"
"github.com/nspcc-dev/neofs-node/pkg/morph/event" "github.com/nspcc-dev/neofs-node/pkg/morph/event"
containerEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/container" containerEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/container"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"github.com/panjf2000/ants/v2" "github.com/panjf2000/ants/v2"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -22,7 +23,7 @@ type (
// Processor of events produced by container contract in the sidechain. // Processor of events produced by container contract in the sidechain.
Processor struct { Processor struct {
log *zap.Logger log *logger.Logger
pool *ants.Pool pool *ants.Pool
alphabetState AlphabetState alphabetState AlphabetState
cnrClient *container.Client // notary must be enabled cnrClient *container.Client // notary must be enabled
@ -34,7 +35,7 @@ type (
// Params of the processor constructor. // Params of the processor constructor.
Params struct { Params struct {
Log *zap.Logger Log *logger.Logger
PoolSize int PoolSize int
AlphabetState AlphabetState AlphabetState AlphabetState
ContainerClient *container.Client ContainerClient *container.Client

View file

@ -12,8 +12,8 @@ import (
nmClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap" nmClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap"
"github.com/nspcc-dev/neofs-node/pkg/morph/event" "github.com/nspcc-dev/neofs-node/pkg/morph/event"
"github.com/nspcc-dev/neofs-node/pkg/morph/event/rolemanagement" "github.com/nspcc-dev/neofs-node/pkg/morph/event/rolemanagement"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"github.com/panjf2000/ants/v2" "github.com/panjf2000/ants/v2"
"go.uber.org/zap"
) )
// ProcessorPoolSize limits the pool size for governance Processor. Processor manages // ProcessorPoolSize limits the pool size for governance Processor. Processor manages
@ -55,7 +55,7 @@ type (
// Processor of events related to governance in the network. // Processor of events related to governance in the network.
Processor struct { Processor struct {
log *zap.Logger log *logger.Logger
pool *ants.Pool pool *ants.Pool
neofsClient *neofscontract.Client neofsClient *neofscontract.Client
netmapClient *nmClient.Client netmapClient *nmClient.Client
@ -75,7 +75,7 @@ type (
// Params of the processor constructor. // Params of the processor constructor.
Params struct { Params struct {
Log *zap.Logger Log *logger.Logger
AlphabetState AlphabetState AlphabetState AlphabetState
EpochState EpochState EpochState EpochState

View file

@ -14,6 +14,7 @@ import (
nmClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap" nmClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap"
"github.com/nspcc-dev/neofs-node/pkg/morph/event" "github.com/nspcc-dev/neofs-node/pkg/morph/event"
neofsEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/neofs" neofsEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/neofs"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"github.com/panjf2000/ants/v2" "github.com/panjf2000/ants/v2"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -36,7 +37,7 @@ type (
// Processor of events produced by neofs contract in main net. // Processor of events produced by neofs contract in main net.
Processor struct { Processor struct {
log *zap.Logger log *logger.Logger
pool *ants.Pool pool *ants.Pool
neofsContract util.Uint160 neofsContract util.Uint160
balanceClient *balance.Client balanceClient *balance.Client
@ -56,7 +57,7 @@ type (
// Params of the processor constructor. // Params of the processor constructor.
Params struct { Params struct {
Log *zap.Logger Log *logger.Logger
PoolSize int PoolSize int
NeoFSContract util.Uint160 NeoFSContract util.Uint160
NeoFSIDClient *neofsid.Client NeoFSIDClient *neofsid.Client

View file

@ -12,6 +12,7 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/morph/event" "github.com/nspcc-dev/neofs-node/pkg/morph/event"
netmapEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/netmap" netmapEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/netmap"
subnetEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/subnet" subnetEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/subnet"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"github.com/nspcc-dev/neofs-sdk-go/netmap" "github.com/nspcc-dev/neofs-sdk-go/netmap"
"github.com/panjf2000/ants/v2" "github.com/panjf2000/ants/v2"
"go.uber.org/zap" "go.uber.org/zap"
@ -54,7 +55,7 @@ type (
// Processor of events produced by network map contract // Processor of events produced by network map contract
// and new epoch ticker, because it is related to contract. // and new epoch ticker, because it is related to contract.
Processor struct { Processor struct {
log *zap.Logger log *logger.Logger
pool *ants.Pool pool *ants.Pool
epochTimer EpochTimerReseter epochTimer EpochTimerReseter
epochState EpochState epochState EpochState
@ -81,7 +82,7 @@ type (
// Params of the processor constructor. // Params of the processor constructor.
Params struct { Params struct {
Log *zap.Logger Log *logger.Logger
PoolSize int PoolSize int
NetmapClient *nmClient.Client NetmapClient *nmClient.Client
EpochTimer EpochTimerReseter EpochTimer EpochTimerReseter

View file

@ -9,6 +9,7 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/morph/event" "github.com/nspcc-dev/neofs-node/pkg/morph/event"
reputationEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/reputation" reputationEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/reputation"
"github.com/nspcc-dev/neofs-node/pkg/services/reputation/common" "github.com/nspcc-dev/neofs-node/pkg/services/reputation/common"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"github.com/panjf2000/ants/v2" "github.com/panjf2000/ants/v2"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -26,7 +27,7 @@ type (
// Processor of events produced by reputation contract. // Processor of events produced by reputation contract.
Processor struct { Processor struct {
log *zap.Logger log *logger.Logger
pool *ants.Pool pool *ants.Pool
epochState EpochState epochState EpochState
@ -41,7 +42,7 @@ type (
// Params of the processor constructor. // Params of the processor constructor.
Params struct { Params struct {
Log *zap.Logger Log *logger.Logger
PoolSize int PoolSize int
EpochState EpochState EpochState EpochState
AlphabetState AlphabetState AlphabetState AlphabetState

View file

@ -53,9 +53,9 @@ var (
// Calculate calculates payments for audit results in a specific epoch of the network. // Calculate calculates payments for audit results in a specific epoch of the network.
// Wraps the results in a money transfer transaction and sends it to the network. // Wraps the results in a money transfer transaction and sends it to the network.
func (c *Calculator) Calculate(p *CalculatePrm) { func (c *Calculator) Calculate(p *CalculatePrm) {
log := c.opts.log.With( log := &logger.Logger{Logger: c.opts.log.With(
zap.Uint64("current epoch", p.Epoch), zap.Uint64("current epoch", p.Epoch),
) )}
if p.Epoch == 0 { if p.Epoch == 0 {
log.Info("settlements are ignored for zero epoch") log.Info("settlements are ignored for zero epoch")
@ -104,10 +104,10 @@ func (c *Calculator) Calculate(p *CalculatePrm) {
} }
func (c *Calculator) processResult(ctx *singleResultCtx) { func (c *Calculator) processResult(ctx *singleResultCtx) {
ctx.log = ctx.log.With( ctx.log = &logger.Logger{Logger: ctx.log.With(
zap.Stringer("cid", ctx.containerID()), zap.Stringer("cid", ctx.containerID()),
zap.Uint64("audit epoch", ctx.auditResult.Epoch()), zap.Uint64("audit epoch", ctx.auditResult.Epoch()),
) )}
ctx.log.Debug("reading information about the container") ctx.log.Debug("reading information about the container")

View file

@ -22,7 +22,7 @@ type options struct {
func defaultOptions() *options { func defaultOptions() *options {
return &options{ return &options{
log: zap.L(), log: &logger.Logger{Logger: zap.L()},
} }
} }

View file

@ -7,8 +7,8 @@ import (
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neofs-node/pkg/innerring/processors/settlement/common" "github.com/nspcc-dev/neofs-node/pkg/innerring/processors/settlement/common"
"github.com/nspcc-dev/neofs-node/pkg/morph/client/container" "github.com/nspcc-dev/neofs-node/pkg/morph/client/container"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"github.com/nspcc-dev/neofs-sdk-go/user" "github.com/nspcc-dev/neofs-sdk-go/user"
"go.uber.org/zap"
) )
type ( type (
@ -28,7 +28,7 @@ type (
IncomeSettlementContext struct { IncomeSettlementContext struct {
mu sync.Mutex // lock to prevent collection and distribution in the same time mu sync.Mutex // lock to prevent collection and distribution in the same time
log *zap.Logger log *logger.Logger
epoch uint64 epoch uint64
rate RateFetcher rate RateFetcher
@ -46,7 +46,7 @@ type (
} }
IncomeSettlementContextPrms struct { IncomeSettlementContextPrms struct {
Log *zap.Logger Log *logger.Logger
Epoch uint64 Epoch uint64
Rate RateFetcher Rate RateFetcher
Estimations EstimationFetcher Estimations EstimationFetcher

View file

@ -2,6 +2,7 @@ package settlement
import ( import (
"github.com/nspcc-dev/neofs-node/pkg/morph/event" "github.com/nspcc-dev/neofs-node/pkg/morph/event"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -12,9 +13,9 @@ func (p *Processor) HandleAuditEvent(e event.Event) {
epoch := ev.Epoch() epoch := ev.Epoch()
log := p.log.With( log := &logger.Logger{Logger: p.log.With(
zap.Uint64("epoch", epoch), zap.Uint64("epoch", epoch),
) )}
log.Info("new audit settlement event") log.Info("new audit settlement event")

View file

@ -19,7 +19,7 @@ func defaultOptions() *options {
return &options{ return &options{
poolSize: poolSize, poolSize: poolSize,
log: zap.L(), log: &logger.Logger{Logger: zap.L()},
} }
} }

View file

@ -13,6 +13,7 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/network/cache" "github.com/nspcc-dev/neofs-node/pkg/network/cache"
"github.com/nspcc-dev/neofs-node/pkg/services/audit/auditor" "github.com/nspcc-dev/neofs-node/pkg/services/audit/auditor"
"github.com/nspcc-dev/neofs-node/pkg/services/object_manager/placement" "github.com/nspcc-dev/neofs-node/pkg/services/object_manager/placement"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status" apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
"github.com/nspcc-dev/neofs-sdk-go/netmap" "github.com/nspcc-dev/neofs-sdk-go/netmap"
"github.com/nspcc-dev/neofs-sdk-go/object" "github.com/nspcc-dev/neofs-sdk-go/object"
@ -23,7 +24,7 @@ import (
type ( type (
ClientCache struct { ClientCache struct {
log *zap.Logger log *logger.Logger
cache interface { cache interface {
Get(clientcore.NodeInfo) (clientcore.Client, error) Get(clientcore.NodeInfo) (clientcore.Client, error)
CloseAll() CloseAll()
@ -34,7 +35,7 @@ type (
} }
clientCacheParams struct { clientCacheParams struct {
Log *zap.Logger Log *logger.Logger
Key *ecdsa.PrivateKey Key *ecdsa.PrivateKey
AllowExternal bool AllowExternal bool

View file

@ -51,7 +51,7 @@ func defaultCfg(с *cfg) {
}, },
fullSizeLimit: 1 << 30, // 1GB fullSizeLimit: 1 << 30, // 1GB
objSizeLimit: 1 << 20, // 1MB objSizeLimit: 1 << 20, // 1MB
log: zap.L(), log: &logger.Logger{Logger: zap.L()},
} }
} }
@ -102,7 +102,7 @@ func WithFullSizeLimit(lim uint64) Option {
// WithLogger returns an option to specify Blobovnicza's logger. // WithLogger returns an option to specify Blobovnicza's logger.
func WithLogger(l *logger.Logger) Option { func WithLogger(l *logger.Logger) Option {
return func(c *cfg) { return func(c *cfg) {
c.log = l.With(zap.String("component", "Blobovnicza")) c.log = &logger.Logger{Logger: l.With(zap.String("component", "Blobovnicza"))}
} }
} }

View file

@ -11,6 +11,7 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/core/object" "github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/common" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/common"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/internal/blobstortest" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/internal/blobstortest"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"github.com/nspcc-dev/neofs-node/pkg/util/logger/test" "github.com/nspcc-dev/neofs-node/pkg/util/logger/test"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object" objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id" oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
@ -135,7 +136,7 @@ func testFillOrder(t *testing.T, depth uint64) {
p, err := os.MkdirTemp("", "*") p, err := os.MkdirTemp("", "*")
require.NoError(t, err) require.NoError(t, err)
b := NewBlobovniczaTree( b := NewBlobovniczaTree(
WithLogger(zaptest.NewLogger(t)), WithLogger(&logger.Logger{Logger: zaptest.NewLogger(t)}),
WithObjectSizeLimit(2048), WithObjectSizeLimit(2048),
WithBlobovniczaShallowWidth(3), WithBlobovniczaShallowWidth(3),
WithBlobovniczaShallowDepth(depth), WithBlobovniczaShallowDepth(depth),

View file

@ -8,6 +8,7 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/common" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/common"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/internal/blobstortest" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/internal/blobstortest"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"go.uber.org/zap/zaptest" "go.uber.org/zap/zaptest"
) )
@ -18,7 +19,7 @@ func TestGeneric(t *testing.T) {
helper := func(t *testing.T, dir string) common.Storage { helper := func(t *testing.T, dir string) common.Storage {
return NewBlobovniczaTree( return NewBlobovniczaTree(
WithLogger(zaptest.NewLogger(t)), WithLogger(&logger.Logger{Logger: zaptest.NewLogger(t)}),
WithObjectSizeLimit(maxObjectSize), WithObjectSizeLimit(maxObjectSize),
WithBlobovniczaShallowWidth(2), WithBlobovniczaShallowWidth(2),
WithBlobovniczaShallowDepth(2), WithBlobovniczaShallowDepth(2),
@ -51,7 +52,7 @@ func TestControl(t *testing.T) {
newTree := func(t *testing.T) common.Storage { newTree := func(t *testing.T) common.Storage {
dir := filepath.Join(t.Name(), strconv.Itoa(n)) dir := filepath.Join(t.Name(), strconv.Itoa(n))
return NewBlobovniczaTree( return NewBlobovniczaTree(
WithLogger(zaptest.NewLogger(t)), WithLogger(&logger.Logger{Logger: zaptest.NewLogger(t)}),
WithObjectSizeLimit(maxObjectSize), WithObjectSizeLimit(maxObjectSize),
WithBlobovniczaShallowWidth(2), WithBlobovniczaShallowWidth(2),
WithBlobovniczaShallowDepth(2), WithBlobovniczaShallowDepth(2),

View file

@ -5,11 +5,12 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobovnicza" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobovnicza"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/compression" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/compression"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"go.uber.org/zap" "go.uber.org/zap"
) )
type cfg struct { type cfg struct {
log *zap.Logger log *logger.Logger
perm fs.FileMode perm fs.FileMode
readOnly bool readOnly bool
rootPath string rootPath string
@ -31,7 +32,7 @@ const (
func initConfig(c *cfg) { func initConfig(c *cfg) {
*c = cfg{ *c = cfg{
log: zap.L(), log: &logger.Logger{Logger: zap.L()},
perm: defaultPerm, perm: defaultPerm,
openedCacheSize: defaultOpenedCacheSize, openedCacheSize: defaultOpenedCacheSize,
blzShallowDepth: defaultBlzShallowDepth, blzShallowDepth: defaultBlzShallowDepth,
@ -39,7 +40,7 @@ func initConfig(c *cfg) {
} }
} }
func WithLogger(l *zap.Logger) Option { func WithLogger(l *logger.Logger) Option {
return func(c *cfg) { return func(c *cfg) {
c.log = l c.log = l
c.blzOpts = append(c.blzOpts, blobovnicza.WithLogger(l)) c.blzOpts = append(c.blzOpts, blobovnicza.WithLogger(l))

View file

@ -46,7 +46,7 @@ type cfg struct {
} }
func initConfig(c *cfg) { func initConfig(c *cfg) {
c.log = zap.L() c.log = &logger.Logger{Logger: zap.L()}
} }
// New creates, initializes and returns new BlobStor instance. // New creates, initializes and returns new BlobStor instance.
@ -66,7 +66,7 @@ func New(opts ...Option) *BlobStor {
} }
// SetLogger sets logger. It is used after the shard ID was generated to use it in logs. // SetLogger sets logger. It is used after the shard ID was generated to use it in logs.
func (b *BlobStor) SetLogger(l *zap.Logger) { func (b *BlobStor) SetLogger(l *logger.Logger) {
b.log = l b.log = l
} }
@ -80,7 +80,7 @@ func WithStorages(st []SubStorage) Option {
// WithLogger returns option to specify BlobStor's logger. // WithLogger returns option to specify BlobStor's logger.
func WithLogger(l *logger.Logger) Option { func WithLogger(l *logger.Logger) Option {
return func(c *cfg) { return func(c *cfg) {
c.log = l.With(zap.String("component", "BlobStor")) c.log = &logger.Logger{Logger: l.With(zap.String("component", "BlobStor"))}
} }
} }

View file

@ -5,6 +5,7 @@ import (
"testing" "testing"
"github.com/nspcc-dev/neofs-node/pkg/core/object" "github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status" apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test" cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object" objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
@ -52,7 +53,7 @@ func TestDeleteBigObject(t *testing.T) {
s3 := testNewShard(t, 3) s3 := testNewShard(t, 3)
e := testNewEngineWithShards(s1, s2, s3) e := testNewEngineWithShards(s1, s2, s3)
e.log = zaptest.NewLogger(t) e.log = &logger.Logger{Logger: zaptest.NewLogger(t)}
defer e.Close() defer e.Close()
for i := range children { for i := range children {

View file

@ -78,7 +78,7 @@ type cfg struct {
func defaultCfg() *cfg { func defaultCfg() *cfg {
return &cfg{ return &cfg{
log: zap.L(), log: &logger.Logger{Logger: zap.L()},
shardPoolSize: 20, shardPoolSize: 20,
} }

View file

@ -12,6 +12,7 @@ import (
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase" meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/pilorama" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/pilorama"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"github.com/nspcc-dev/neofs-sdk-go/checksum" "github.com/nspcc-dev/neofs-sdk-go/checksum"
checksumtest "github.com/nspcc-dev/neofs-sdk-go/checksum/test" checksumtest "github.com/nspcc-dev/neofs-sdk-go/checksum/test"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id" cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
@ -121,7 +122,7 @@ func testNewShard(t testing.TB, id int) *shard.Shard {
s := shard.New( s := shard.New(
shard.WithID(sid), shard.WithID(sid),
shard.WithLogger(zap.L()), shard.WithLogger(&logger.Logger{Logger: zap.L()}),
shard.WithBlobStorOptions( shard.WithBlobStorOptions(
blobstor.WithStorages( blobstor.WithStorages(
newStorages(filepath.Join(t.Name(), fmt.Sprintf("%d.blobstor", id)), newStorages(filepath.Join(t.Name(), fmt.Sprintf("%d.blobstor", id)),

View file

@ -13,6 +13,7 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/pilorama" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/pilorama"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard/mode" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard/mode"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status" apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test" cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object" objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
@ -32,7 +33,7 @@ func newEngineWithErrorThreshold(t testing.TB, dir string, errThreshold uint32)
} }
e := New( e := New(
WithLogger(zaptest.NewLogger(t)), WithLogger(&logger.Logger{Logger: zaptest.NewLogger(t)}),
WithShardPoolSize(1), WithShardPoolSize(1),
WithErrorThreshold(errThreshold)) WithErrorThreshold(errThreshold))
@ -41,7 +42,7 @@ func newEngineWithErrorThreshold(t testing.TB, dir string, errThreshold uint32)
for i := range ids { for i := range ids {
ids[i], err = e.AddShard( ids[i], err = e.AddShard(
shard.WithLogger(zaptest.NewLogger(t)), shard.WithLogger(&logger.Logger{Logger: zaptest.NewLogger(t)}),
shard.WithBlobStorOptions( shard.WithBlobStorOptions(
blobstor.WithStorages(newStorages(filepath.Join(dir, strconv.Itoa(i)), errSmallSize))), blobstor.WithStorages(newStorages(filepath.Join(dir, strconv.Itoa(i)), errSmallSize))),
shard.WithMetaBaseOptions( shard.WithMetaBaseOptions(

View file

@ -14,6 +14,7 @@ import (
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase" meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard/mode" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard/mode"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test" cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object" objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id" oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
@ -27,14 +28,14 @@ func newEngineEvacuate(t *testing.T, shardNum int, objPerShard int) (*StorageEng
t.Cleanup(func() { _ = os.RemoveAll(dir) }) t.Cleanup(func() { _ = os.RemoveAll(dir) })
e := New( e := New(
WithLogger(zaptest.NewLogger(t)), WithLogger(&logger.Logger{Logger: zaptest.NewLogger(t)}),
WithShardPoolSize(1)) WithShardPoolSize(1))
ids := make([]*shard.ID, shardNum) ids := make([]*shard.ID, shardNum)
for i := range ids { for i := range ids {
ids[i], err = e.AddShard( ids[i], err = e.AddShard(
shard.WithLogger(zaptest.NewLogger(t)), shard.WithLogger(&logger.Logger{Logger: zaptest.NewLogger(t)}),
shard.WithBlobStorOptions( shard.WithBlobStorOptions(
blobstor.WithStorages([]blobstor.SubStorage{{ blobstor.WithStorages([]blobstor.SubStorage{{
Storage: fstree.New( Storage: fstree.New(

View file

@ -69,7 +69,7 @@ func defaultCfg() *cfg {
}, },
boltBatchDelay: bbolt.DefaultMaxBatchDelay, boltBatchDelay: bbolt.DefaultMaxBatchDelay,
boltBatchSize: bbolt.DefaultMaxBatchSize, boltBatchSize: bbolt.DefaultMaxBatchSize,
log: zap.L(), log: &logger.Logger{Logger: zap.L()},
} }
} }
@ -288,7 +288,7 @@ func bucketKeyHelper(hdr string, val string) []byte {
} }
// SetLogger sets logger. It is used after the shard ID was generated to use it in logs. // SetLogger sets logger. It is used after the shard ID was generated to use it in logs.
func (db *DB) SetLogger(l *zap.Logger) { func (db *DB) SetLogger(l *logger.Logger) {
db.log = l db.log = l
} }

View file

@ -13,6 +13,7 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/pilorama" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/pilorama"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard/mode" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard/mode"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/writecache" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/writecache"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status" apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id" cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test" cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
@ -36,7 +37,7 @@ func TestShardOpen(t *testing.T) {
newShard := func() *Shard { newShard := func() *Shard {
return New( return New(
WithLogger(zaptest.NewLogger(t)), WithLogger(&logger.Logger{Logger: zaptest.NewLogger(t)}),
WithBlobStorOptions( WithBlobStorOptions(
blobstor.WithStorages([]blobstor.SubStorage{ blobstor.WithStorages([]blobstor.SubStorage{
{ {

View file

@ -18,6 +18,7 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard/mode" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard/mode"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/writecache" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/writecache"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test" cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object" objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id" oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
@ -52,7 +53,7 @@ func testDump(t *testing.T, objCount int, hasWriteCache bool) {
[]writecache.Option{ []writecache.Option{
writecache.WithSmallObjectSize(wcSmallObjectSize), writecache.WithSmallObjectSize(wcSmallObjectSize),
writecache.WithMaxObjectSize(wcBigObjectSize), writecache.WithMaxObjectSize(wcBigObjectSize),
writecache.WithLogger(zaptest.NewLogger(t)), writecache.WithLogger(&logger.Logger{Logger: zaptest.NewLogger(t)}),
}, },
nil) nil)
} }

View file

@ -85,7 +85,7 @@ type gcCfg struct {
func defaultGCCfg() *gcCfg { func defaultGCCfg() *gcCfg {
return &gcCfg{ return &gcCfg{
removerInterval: 10 * time.Second, removerInterval: 10 * time.Second,
log: zap.L(), log: &logger.Logger{Logger: zap.L()},
workerPoolInit: func(int) util.WorkerPool { workerPoolInit: func(int) util.WorkerPool {
return nil return nil
}, },

View file

@ -2,6 +2,7 @@ package shard
import ( import (
"github.com/mr-tron/base58" "github.com/mr-tron/base58"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -44,7 +45,7 @@ func (s *Shard) UpdateID() (err error) {
s.info.ID = NewIDFromBytes(id) s.info.ID = NewIDFromBytes(id)
} }
s.log = s.log.With(zap.String("shard_id", s.info.ID.String())) s.log = &logger.Logger{Logger: s.log.With(zap.String("shard_id", s.info.ID.String()))}
s.metaBase.SetLogger(s.log) s.metaBase.SetLogger(s.log)
s.blobStor.SetLogger(s.log) s.blobStor.SetLogger(s.log)
if s.hasWriteCache() { if s.hasWriteCache() {

View file

@ -11,6 +11,7 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/fstree" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/fstree"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase" meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status" apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test" cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
"github.com/nspcc-dev/neofs-sdk-go/object" "github.com/nspcc-dev/neofs-sdk-go/object"
@ -24,7 +25,7 @@ func TestShard_Lock(t *testing.T) {
rootPath := t.TempDir() rootPath := t.TempDir()
opts := []shard.Option{ opts := []shard.Option{
shard.WithLogger(zap.NewNop()), shard.WithLogger(&logger.Logger{Logger: zap.NewNop()}),
shard.WithBlobStorOptions( shard.WithBlobStorOptions(
blobstor.WithStorages([]blobstor.SubStorage{ blobstor.WithStorages([]blobstor.SubStorage{
{ {

View file

@ -12,6 +12,7 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/fstree" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/fstree"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/writecache" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/writecache"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status" apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object" objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@ -69,7 +70,7 @@ func testShardGetRange(t *testing.T, hasWriteCache bool) {
[]blobstor.Option{blobstor.WithStorages([]blobstor.SubStorage{ []blobstor.Option{blobstor.WithStorages([]blobstor.SubStorage{
{ {
Storage: blobovniczatree.NewBlobovniczaTree( Storage: blobovniczatree.NewBlobovniczaTree(
blobovniczatree.WithLogger(zaptest.NewLogger(t)), blobovniczatree.WithLogger(&logger.Logger{Logger: zaptest.NewLogger(t)}),
blobovniczatree.WithRootPath(filepath.Join(t.TempDir(), "blob", "blobovnicza")), blobovniczatree.WithRootPath(filepath.Join(t.TempDir(), "blob", "blobovnicza")),
blobovniczatree.WithBlobovniczaShallowDepth(1), blobovniczatree.WithBlobovniczaShallowDepth(1),
blobovniczatree.WithBlobovniczaShallowWidth(1)), blobovniczatree.WithBlobovniczaShallowWidth(1)),

View file

@ -98,7 +98,7 @@ type cfg struct {
func defaultCfg() *cfg { func defaultCfg() *cfg {
return &cfg{ return &cfg{
rmBatchSize: 100, rmBatchSize: 100,
log: zap.L(), log: &logger.Logger{Logger: zap.L()},
gcCfg: defaultGCCfg(), gcCfg: defaultGCCfg(),
} }
} }

View file

@ -13,6 +13,7 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/pilorama" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/pilorama"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/writecache" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/writecache"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"github.com/nspcc-dev/neofs-sdk-go/checksum" "github.com/nspcc-dev/neofs-sdk-go/checksum"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id" cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test" cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
@ -47,11 +48,11 @@ func newCustomShard(t testing.TB, rootPath string, enableWriteCache bool, wcOpts
if bsOpts == nil { if bsOpts == nil {
bsOpts = []blobstor.Option{ bsOpts = []blobstor.Option{
blobstor.WithLogger(zaptest.NewLogger(t)), blobstor.WithLogger(&logger.Logger{Logger: zaptest.NewLogger(t)}),
blobstor.WithStorages([]blobstor.SubStorage{ blobstor.WithStorages([]blobstor.SubStorage{
{ {
Storage: blobovniczatree.NewBlobovniczaTree( Storage: blobovniczatree.NewBlobovniczaTree(
blobovniczatree.WithLogger(zaptest.NewLogger(t)), blobovniczatree.WithLogger(&logger.Logger{Logger: zaptest.NewLogger(t)}),
blobovniczatree.WithRootPath(filepath.Join(rootPath, "blob", "blobovnicza")), blobovniczatree.WithRootPath(filepath.Join(rootPath, "blob", "blobovnicza")),
blobovniczatree.WithBlobovniczaShallowDepth(1), blobovniczatree.WithBlobovniczaShallowDepth(1),
blobovniczatree.WithBlobovniczaShallowWidth(1)), blobovniczatree.WithBlobovniczaShallowWidth(1)),
@ -68,7 +69,7 @@ func newCustomShard(t testing.TB, rootPath string, enableWriteCache bool, wcOpts
} }
opts := []shard.Option{ opts := []shard.Option{
shard.WithLogger(zap.L()), shard.WithLogger(&logger.Logger{Logger: zap.L()}),
shard.WithBlobStorOptions(bsOpts...), shard.WithBlobStorOptions(bsOpts...),
shard.WithMetaBaseOptions( shard.WithMetaBaseOptions(
meta.WithPath(filepath.Join(rootPath, "meta")), meta.WithPath(filepath.Join(rootPath, "meta")),

View file

@ -11,6 +11,7 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/fstree" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/fstree"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase" meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard/mode" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard/mode"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
checksumtest "github.com/nspcc-dev/neofs-sdk-go/checksum/test" checksumtest "github.com/nspcc-dev/neofs-sdk-go/checksum/test"
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test" cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
"github.com/nspcc-dev/neofs-sdk-go/object" "github.com/nspcc-dev/neofs-sdk-go/object"
@ -53,7 +54,7 @@ func TestFlush(t *testing.T) {
require.NoError(t, bs.Init()) require.NoError(t, bs.Init())
wc := New( wc := New(
WithLogger(zaptest.NewLogger(t)), WithLogger(&logger.Logger{Logger: zaptest.NewLogger(t)}),
WithPath(filepath.Join(dir, "writecache")), WithPath(filepath.Join(dir, "writecache")),
WithSmallObjectSize(smallSize), WithSmallObjectSize(smallSize),
WithMetabase(mb), WithMetabase(mb),

View file

@ -7,6 +7,7 @@ import (
"testing" "testing"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/internal/storagetest" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/internal/storagetest"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"go.uber.org/zap/zaptest" "go.uber.org/zap/zaptest"
) )
@ -20,7 +21,7 @@ func TestGeneric(t *testing.T) {
dir := filepath.Join(t.Name(), strconv.Itoa(n)) dir := filepath.Join(t.Name(), strconv.Itoa(n))
require.NoError(t, os.MkdirAll(dir, os.ModePerm)) require.NoError(t, os.MkdirAll(dir, os.ModePerm))
return New( return New(
WithLogger(zaptest.NewLogger(t)), WithLogger(&logger.Logger{Logger: zaptest.NewLogger(t)}),
WithFlushWorkersCount(2), WithFlushWorkersCount(2),
WithPath(dir)) WithPath(dir))
} }

View file

@ -6,6 +6,7 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/common" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/common"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase" meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object" objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -27,7 +28,7 @@ type blob interface {
} }
type options struct { type options struct {
log *zap.Logger log *logger.Logger
// path is a path to a directory for write-cache. // path is a path to a directory for write-cache.
path string path string
// blobstor is the main persistent storage. // blobstor is the main persistent storage.
@ -52,9 +53,9 @@ type options struct {
} }
// WithLogger sets logger. // WithLogger sets logger.
func WithLogger(log *zap.Logger) Option { func WithLogger(log *logger.Logger) Option {
return func(o *options) { return func(o *options) {
o.log = log.With(zap.String("component", "WriteCache")) o.log = &logger.Logger{Logger: log.With(zap.String("component", "WriteCache"))}
} }
} }

View file

@ -6,6 +6,7 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/common" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/common"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/fstree" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/fstree"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard/mode" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard/mode"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"github.com/nspcc-dev/neofs-sdk-go/object" "github.com/nspcc-dev/neofs-sdk-go/object"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id" oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
"go.etcd.io/bbolt" "go.etcd.io/bbolt"
@ -26,7 +27,7 @@ type Cache interface {
Iterate(IterationPrm) error Iterate(IterationPrm) error
Put(common.PutPrm) (common.PutRes, error) Put(common.PutPrm) (common.PutRes, error)
SetMode(mode.Mode) error SetMode(mode.Mode) error
SetLogger(*zap.Logger) SetLogger(*logger.Logger)
DumpInfo() Info DumpInfo() Info
Flush(bool) error Flush(bool) error
@ -84,7 +85,7 @@ func New(opts ...Option) Cache {
compressFlags: make(map[string]struct{}), compressFlags: make(map[string]struct{}),
options: options{ options: options{
log: zap.NewNop(), log: &logger.Logger{Logger: zap.NewNop()},
maxObjectSize: defaultMaxObjectSize, maxObjectSize: defaultMaxObjectSize,
smallObjectSize: defaultSmallObjectSize, smallObjectSize: defaultSmallObjectSize,
workersCount: defaultFlushWorkersCount, workersCount: defaultFlushWorkersCount,
@ -108,7 +109,7 @@ func New(opts ...Option) Cache {
} }
// SetLogger sets logger. It is used after the shard ID was generated to use it in logs. // SetLogger sets logger. It is used after the shard ID was generated to use it in logs.
func (c *cache) SetLogger(l *zap.Logger) { func (c *cache) SetLogger(l *logger.Logger) {
c.log = l c.log = l
} }

View file

@ -55,7 +55,7 @@ func defaultConfig() *cfg {
return &cfg{ return &cfg{
ctx: context.Background(), ctx: context.Background(),
dialTimeout: defaultDialTimeout, dialTimeout: defaultDialTimeout,
logger: zap.L(), logger: &logger.Logger{Logger: zap.L()},
waitInterval: defaultWaitInterval, waitInterval: defaultWaitInterval,
signer: &transaction.Signer{ signer: &transaction.Signer{
Scopes: transaction.Global, Scopes: transaction.Global,
@ -75,7 +75,7 @@ func defaultConfig() *cfg {
// - blockchain network type: netmode.PrivNet; // - blockchain network type: netmode.PrivNet;
// - signer with the global scope; // - signer with the global scope;
// - wait interval: 500ms; // - wait interval: 500ms;
// - logger: zap.L(). // - logger: &logger.Logger{Logger: zap.L()}.
// //
// If desired option satisfies the default value, it can be omitted. // If desired option satisfies the default value, it can be omitted.
// If multiple options of the same config value are supplied, // If multiple options of the same config value are supplied,
@ -238,7 +238,7 @@ func WithDialTimeout(dur time.Duration) Option {
// //
// Ignores nil value. // Ignores nil value.
// //
// If option not provided, zap.L() is used. // If option not provided, &logger.Logger{Logger: zap.L()} is used.
func WithLogger(logger *logger.Logger) Option { func WithLogger(logger *logger.Logger) Option {
return func(c *cfg) { return func(c *cfg) {
if logger != nil { if logger != nil {

View file

@ -12,6 +12,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/client"
"github.com/nspcc-dev/neofs-node/pkg/morph/subscriber" "github.com/nspcc-dev/neofs-node/pkg/morph/subscriber"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"github.com/panjf2000/ants/v2" "github.com/panjf2000/ants/v2"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -84,7 +85,7 @@ type Listener interface {
// ListenerParams is a group of parameters // ListenerParams is a group of parameters
// for Listener constructor. // for Listener constructor.
type ListenerParams struct { type ListenerParams struct {
Logger *zap.Logger Logger *logger.Logger
Subscriber subscriber.Subscriber Subscriber subscriber.Subscriber
@ -107,7 +108,7 @@ type listener struct {
notaryHandlers map[notaryRequestTypes]Handler notaryHandlers map[notaryRequestTypes]Handler
notaryMainTXSigner util.Uint160 // filter for notary subscription notaryMainTXSigner util.Uint160 // filter for notary subscription
log *zap.Logger log *logger.Logger
subscriber subscriber.Subscriber subscriber subscriber.Subscriber

View file

@ -10,6 +10,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
"github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/client"
util2 "github.com/nspcc-dev/neofs-node/pkg/util" util2 "github.com/nspcc-dev/neofs-node/pkg/util"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -81,7 +82,7 @@ func (s typeValue) GetType() Type {
} }
// WorkerPoolHandler sets closure over worker pool w with passed handler h. // WorkerPoolHandler sets closure over worker pool w with passed handler h.
func WorkerPoolHandler(w util2.WorkerPool, h Handler, log *zap.Logger) Handler { func WorkerPoolHandler(w util2.WorkerPool, h Handler, log *logger.Logger) Handler {
return func(e Event) { return func(e Event) {
err := w.Submit(func() { err := w.Submit(func() {
h(e) h(e)

View file

@ -12,6 +12,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/neorpc/result" "github.com/nspcc-dev/neo-go/pkg/neorpc/result"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/client"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -27,7 +28,7 @@ type (
subscriber struct { subscriber struct {
*sync.RWMutex *sync.RWMutex
log *zap.Logger log *logger.Logger
client *client.Client client *client.Client
notifyChan chan *state.ContainedNotificationEvent notifyChan chan *state.ContainedNotificationEvent
@ -39,7 +40,7 @@ type (
// Params is a group of Subscriber constructor parameters. // Params is a group of Subscriber constructor parameters.
Params struct { Params struct {
Log *zap.Logger Log *logger.Logger
StartFromBlock uint32 StartFromBlock uint32
Client *client.Client Client *client.Client
} }

View file

@ -191,9 +191,9 @@ func (c *Context) init() {
c.headResponses = make(map[string]shortHeader) c.headResponses = make(map[string]shortHeader)
c.log = c.log.With( c.log = &logger.Logger{Logger: c.log.With(
zap.Stringer("container ID", c.task.ContainerID()), zap.Stringer("container ID", c.task.ContainerID()),
) )}
} }
func (c *Context) expired() bool { func (c *Context) expired() bool {

View file

@ -34,7 +34,7 @@ type cfg struct {
func defaultCfg() *cfg { func defaultCfg() *cfg {
return &cfg{ return &cfg{
log: zap.L(), log: &logger.Logger{Logger: zap.L()},
} }
} }
@ -54,7 +54,7 @@ func New(opts ...Option) *Manager {
// WithLogger returns option to specify Manager's logger. // WithLogger returns option to specify Manager's logger.
func WithLogger(l *logger.Logger) Option { func WithLogger(l *logger.Logger) Option {
return func(c *cfg) { return func(c *cfg) {
c.log = l.With(zap.String("component", "Audit task manager")) c.log = &logger.Logger{Logger: l.With(zap.String("component", "Audit task manager"))}
c.ctxPrm.SetLogger(l) c.ctxPrm.SetLogger(l)
} }
} }

View file

@ -125,9 +125,9 @@ func (c *Controller) acquireAnnouncement(prm StartPrm) *announceContext {
c.announceMtx.Unlock() c.announceMtx.Unlock()
log := c.opts.log.With( log := &logger.Logger{Logger: c.opts.log.With(
zap.Uint64("epoch", prm.Epoch), zap.Uint64("epoch", prm.Epoch),
) )}
if ctx == nil { if ctx == nil {
log.Debug("announcement is already started") log.Debug("announcement is already started")
@ -217,9 +217,9 @@ func (c *Controller) acquireReport(prm StopPrm) *stopContext {
c.reportMtx.Unlock() c.reportMtx.Unlock()
log := c.opts.log.With( log := &logger.Logger{Logger: c.opts.log.With(
zap.Uint64("epoch", prm.Epoch), zap.Uint64("epoch", prm.Epoch),
) )}
if ctx == nil { if ctx == nil {
log.Debug("report is already started") log.Debug("report is already started")

View file

@ -14,7 +14,7 @@ type options struct {
func defaultOpts() *options { func defaultOpts() *options {
return &options{ return &options{
log: zap.L(), log: &logger.Logger{Logger: zap.L()},
} }
} }

View file

@ -14,7 +14,7 @@ type options struct {
func defaultOpts() *options { func defaultOpts() *options {
return &options{ return &options{
log: zap.L(), log: &logger.Logger{Logger: zap.L()},
} }
} }

View file

@ -4,7 +4,7 @@ import (
"time" "time"
"github.com/nats-io/nats.go" "github.com/nats-io/nats.go"
"go.uber.org/zap" "github.com/nspcc-dev/neofs-node/pkg/util/logger"
) )
func WithClientCert(certPath, keyPath string) Option { func WithClientCert(certPath, keyPath string) Option {
@ -31,7 +31,7 @@ func WithConnectionName(name string) Option {
} }
} }
func WithLogger(logger *zap.Logger) Option { func WithLogger(logger *logger.Logger) Option {
return func(o *opts) { return func(o *opts) {
o.log = logger o.log = logger
} }

View file

@ -7,6 +7,7 @@ import (
"sync" "sync"
"github.com/nats-io/nats.go" "github.com/nats-io/nats.go"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id" oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -29,7 +30,7 @@ type Writer struct {
} }
type opts struct { type opts struct {
log *zap.Logger log *logger.Logger
nOpts []nats.Option nOpts []nats.Option
} }
@ -85,7 +86,7 @@ func New(oo ...Option) *Writer {
m: &sync.RWMutex{}, m: &sync.RWMutex{},
createdStreams: make(map[string]struct{}), createdStreams: make(map[string]struct{}),
opts: opts{ opts: opts{
log: zap.L(), log: &logger.Logger{Logger: zap.L()},
nOpts: make([]nats.Option, 0, len(oo)+3), nOpts: make([]nats.Option, 0, len(oo)+3),
}, },
} }

View file

@ -3,6 +3,7 @@ package notificator
import ( import (
"fmt" "fmt"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id" oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -12,11 +13,11 @@ import (
type Prm struct { type Prm struct {
writer NotificationWriter writer NotificationWriter
notificationSource NotificationSource notificationSource NotificationSource
logger *zap.Logger logger *logger.Logger
} }
// SetLogger sets a logger. // SetLogger sets a logger.
func (prm *Prm) SetLogger(v *zap.Logger) *Prm { func (prm *Prm) SetLogger(v *logger.Logger) *Prm {
prm.logger = v prm.logger = v
return prm return prm
} }
@ -43,7 +44,7 @@ func (prm *Prm) SetNotificationSource(v NotificationSource) *Prm {
type Notificator struct { type Notificator struct {
w NotificationWriter w NotificationWriter
ns NotificationSource ns NotificationSource
l *zap.Logger l *logger.Logger
} }
// New creates, initializes and returns the Notificator instance. // New creates, initializes and returns the Notificator instance.

View file

@ -5,6 +5,7 @@ import (
"crypto/sha256" "crypto/sha256"
core "github.com/nspcc-dev/neofs-node/pkg/core/netmap" core "github.com/nspcc-dev/neofs-node/pkg/core/netmap"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"github.com/nspcc-dev/neofs-sdk-go/container" "github.com/nspcc-dev/neofs-sdk-go/container"
"github.com/nspcc-dev/neofs-sdk-go/container/acl" "github.com/nspcc-dev/neofs-sdk-go/container/acl"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id" cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
@ -13,7 +14,7 @@ import (
) )
type senderClassifier struct { type senderClassifier struct {
log *zap.Logger log *logger.Logger
innerRing InnerRingFetcher innerRing InnerRingFetcher
netmap core.Source netmap core.Source
} }

View file

@ -4,11 +4,11 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/core/container" "github.com/nspcc-dev/neofs-node/pkg/core/container"
"github.com/nspcc-dev/neofs-node/pkg/core/netmap" "github.com/nspcc-dev/neofs-node/pkg/core/netmap"
objectSvc "github.com/nspcc-dev/neofs-node/pkg/services/object" objectSvc "github.com/nspcc-dev/neofs-node/pkg/services/object"
"go.uber.org/zap" "github.com/nspcc-dev/neofs-node/pkg/util/logger"
) )
// WithLogger returns option to set logger. // WithLogger returns option to set logger.
func WithLogger(v *zap.Logger) Option { func WithLogger(v *logger.Logger) Option {
return func(c *cfg) { return func(c *cfg) {
c.log = v c.log = v
} }

View file

@ -9,6 +9,7 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/core/container" "github.com/nspcc-dev/neofs-node/pkg/core/container"
"github.com/nspcc-dev/neofs-node/pkg/core/netmap" "github.com/nspcc-dev/neofs-node/pkg/core/netmap"
"github.com/nspcc-dev/neofs-node/pkg/services/object" "github.com/nspcc-dev/neofs-node/pkg/services/object"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"github.com/nspcc-dev/neofs-sdk-go/container/acl" "github.com/nspcc-dev/neofs-sdk-go/container/acl"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id" cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id" oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
@ -57,7 +58,7 @@ type searchStreamBasicChecker struct {
type Option func(*cfg) type Option func(*cfg)
type cfg struct { type cfg struct {
log *zap.Logger log *logger.Logger
containers container.Source containers container.Source
@ -72,7 +73,7 @@ type cfg struct {
func defaultCfg() *cfg { func defaultCfg() *cfg {
return &cfg{ return &cfg{
log: zap.L(), log: &logger.Logger{Logger: zap.L()},
} }
} }

View file

@ -42,13 +42,13 @@ const (
) )
func (exec *execCtx) setLogger(l *logger.Logger) { func (exec *execCtx) setLogger(l *logger.Logger) {
exec.log = l.With( exec.log = &logger.Logger{Logger: l.With(
zap.String("request", "DELETE"), zap.String("request", "DELETE"),
zap.Stringer("address", exec.address()), zap.Stringer("address", exec.address()),
zap.Bool("local", exec.isLocal()), zap.Bool("local", exec.isLocal()),
zap.Bool("with session", exec.prm.common.SessionToken() != nil), zap.Bool("with session", exec.prm.common.SessionToken() != nil),
zap.Bool("with bearer", exec.prm.common.BearerToken() != nil), zap.Bool("with bearer", exec.prm.common.BearerToken() != nil),
) )}
} }
func (exec execCtx) context() context.Context { func (exec execCtx) context() context.Context {

View file

@ -62,7 +62,7 @@ type cfg struct {
func defaultCfg() *cfg { func defaultCfg() *cfg {
return &cfg{ return &cfg{
log: zap.L(), log: &logger.Logger{Logger: zap.L()},
} }
} }
@ -83,7 +83,7 @@ func New(opts ...Option) *Service {
// WithLogger returns option to specify Delete service's logger. // WithLogger returns option to specify Delete service's logger.
func WithLogger(l *logger.Logger) Option { func WithLogger(l *logger.Logger) Option {
return func(c *cfg) { return func(c *cfg) {
c.log = l.With(zap.String("component", "Object.Delete service")) c.log = &logger.Logger{Logger: l.With(zap.String("component", "Object.Delete service"))}
} }
} }

View file

@ -73,14 +73,14 @@ func (exec *execCtx) setLogger(l *logger.Logger) {
req = "GET_RANGE" req = "GET_RANGE"
} }
exec.log = l.With( exec.log = &logger.Logger{Logger: l.With(
zap.String("request", req), zap.String("request", req),
zap.Stringer("address", exec.address()), zap.Stringer("address", exec.address()),
zap.Bool("raw", exec.isRaw()), zap.Bool("raw", exec.isRaw()),
zap.Bool("local", exec.isLocal()), zap.Bool("local", exec.isLocal()),
zap.Bool("with session", exec.prm.common.SessionToken() != nil), zap.Bool("with session", exec.prm.common.SessionToken() != nil),
zap.Bool("with bearer", exec.prm.common.BearerToken() != nil), zap.Bool("with bearer", exec.prm.common.BearerToken() != nil),
) )}
} }
func (exec execCtx) context() context.Context { func (exec execCtx) context() context.Context {

View file

@ -52,7 +52,7 @@ type cfg struct {
func defaultCfg() *cfg { func defaultCfg() *cfg {
return &cfg{ return &cfg{
assembly: true, assembly: true,
log: zap.L(), log: &logger.Logger{Logger: zap.L()},
localStorage: new(storageEngineWrapper), localStorage: new(storageEngineWrapper),
clientCache: new(clientCacheWrapper), clientCache: new(clientCacheWrapper),
} }
@ -75,7 +75,7 @@ func New(opts ...Option) *Service {
// WithLogger returns option to specify Get service's logger. // WithLogger returns option to specify Get service's logger.
func WithLogger(l *logger.Logger) Option { func WithLogger(l *logger.Logger) Option {
return func(c *cfg) { return func(c *cfg) {
c.log = l.With(zap.String("component", "Object.Get service")) c.log = &logger.Logger{Logger: l.With(zap.String("component", "Object.Get service"))}
} }
} }

View file

@ -61,7 +61,7 @@ func defaultCfg() *cfg {
return &cfg{ return &cfg{
remotePool: util.NewPseudoWorkerPool(), remotePool: util.NewPseudoWorkerPool(),
localPool: util.NewPseudoWorkerPool(), localPool: util.NewPseudoWorkerPool(),
log: zap.L(), log: &logger.Logger{Logger: zap.L()},
} }
} }

View file

@ -42,13 +42,13 @@ func (exec *execCtx) prepare() {
} }
func (exec *execCtx) setLogger(l *logger.Logger) { func (exec *execCtx) setLogger(l *logger.Logger) {
exec.log = l.With( exec.log = &logger.Logger{Logger: l.With(
zap.String("request", "SEARCH"), zap.String("request", "SEARCH"),
zap.Stringer("container", exec.containerID()), zap.Stringer("container", exec.containerID()),
zap.Bool("local", exec.isLocal()), zap.Bool("local", exec.isLocal()),
zap.Bool("with session", exec.prm.common.SessionToken() != nil), zap.Bool("with session", exec.prm.common.SessionToken() != nil),
zap.Bool("with bearer", exec.prm.common.BearerToken() != nil), zap.Bool("with bearer", exec.prm.common.BearerToken() != nil),
) )}
} }
func (exec execCtx) context() context.Context { func (exec execCtx) context() context.Context {

View file

@ -55,7 +55,7 @@ type cfg struct {
func defaultCfg() *cfg { func defaultCfg() *cfg {
return &cfg{ return &cfg{
log: zap.L(), log: &logger.Logger{Logger: zap.L()},
clientConstructor: new(clientConstructorWrapper), clientConstructor: new(clientConstructorWrapper),
} }
} }
@ -77,7 +77,7 @@ func New(opts ...Option) *Service {
// WithLogger returns option to specify Get service's logger. // WithLogger returns option to specify Get service's logger.
func WithLogger(l *logger.Logger) Option { func WithLogger(l *logger.Logger) Option {
return func(c *cfg) { return func(c *cfg) {
c.log = l.With(zap.String("component", "Object.Search service")) c.log = &logger.Logger{Logger: l.With(zap.String("component", "Object.Search service"))}
} }
} }

View file

@ -6,6 +6,7 @@ import (
lru "github.com/hashicorp/golang-lru" lru "github.com/hashicorp/golang-lru"
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object" objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"github.com/nspcc-dev/neofs-sdk-go/object" "github.com/nspcc-dev/neofs-sdk-go/object"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id" oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
"go.uber.org/zap" "go.uber.org/zap"
@ -32,7 +33,7 @@ type Source interface {
type ExpirationChecker struct { type ExpirationChecker struct {
cache *lru.Cache cache *lru.Cache
log *zap.Logger log *logger.Logger
tsSource Source tsSource Source
} }

View file

@ -4,13 +4,14 @@ import (
"fmt" "fmt"
lru "github.com/hashicorp/golang-lru" lru "github.com/hashicorp/golang-lru"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"go.uber.org/zap" "go.uber.org/zap"
) )
const defaultLRUCacheSize = 100 const defaultLRUCacheSize = 100
type cfg struct { type cfg struct {
log *zap.Logger log *logger.Logger
cacheSize int cacheSize int
@ -22,7 +23,7 @@ type Option func(*cfg)
func defaultCfg() *cfg { func defaultCfg() *cfg {
return &cfg{ return &cfg{
log: zap.NewNop(), log: &logger.Logger{Logger: zap.NewNop()},
cacheSize: defaultLRUCacheSize, cacheSize: defaultLRUCacheSize,
} }
} }
@ -61,7 +62,7 @@ func NewChecker(oo ...Option) *ExpirationChecker {
// WithLogger returns an option to specify // WithLogger returns an option to specify
// logger. // logger.
func WithLogger(v *zap.Logger) Option { func WithLogger(v *logger.Logger) Option {
return func(c *cfg) { return func(c *cfg) {
c.log = v c.log = v
} }

View file

@ -97,7 +97,7 @@ type cfg struct {
func defaultCfg() *cfg { func defaultCfg() *cfg {
return &cfg{ return &cfg{
log: zap.L(), log: &logger.Logger{Logger: zap.L()},
batchSize: 10, batchSize: 10,
cacheSize: 200_000, // should not allocate more than 200 MiB cacheSize: 200_000, // should not allocate more than 200 MiB
rebalanceFreq: 1 * time.Second, rebalanceFreq: 1 * time.Second,
@ -113,7 +113,7 @@ func New(opts ...Option) *Policer {
opts[i](c) opts[i](c)
} }
c.log = c.log.With(zap.String("component", "Object Policer")) c.log = &logger.Logger{Logger: c.log.With(zap.String("component", "Object Policer"))}
cache, err := lru.New(int(c.cacheSize)) cache, err := lru.New(int(c.cacheSize))
if err != nil { if err != nil {

View file

@ -40,7 +40,7 @@ func New(opts ...Option) *Replicator {
opts[i](c) opts[i](c)
} }
c.log = c.log.With(zap.String("component", "Object Replicator")) c.log = &logger.Logger{Logger: c.log.With(zap.String("component", "Object Replicator"))}
return &Replicator{ return &Replicator{
cfg: c, cfg: c,

View file

@ -118,7 +118,7 @@ type MngOption func(*mngOptions)
func defaultMngOpts() *mngOptions { func defaultMngOpts() *mngOptions {
return &mngOptions{ return &mngOptions{
log: zap.L(), log: &logger.Logger{Logger: zap.L()},
} }
} }

View file

@ -14,7 +14,7 @@ type options struct {
func defaultOpts() *options { func defaultOpts() *options {
return &options{ return &options{
log: zap.L(), log: &logger.Logger{Logger: zap.L()},
} }
} }

View file

@ -14,7 +14,7 @@ type options struct {
func defaultOpts() *options { func defaultOpts() *options {
return &options{ return &options{
log: zap.L(), log: &logger.Logger{Logger: zap.L()},
} }
} }

View file

@ -14,7 +14,7 @@ type options struct {
func defaultOpts() *options { func defaultOpts() *options {
return &options{ return &options{
log: zap.L(), log: &logger.Logger{Logger: zap.L()},
} }
} }

View file

@ -75,9 +75,9 @@ func (c *Controller) acquireReport(epoch uint64) *reportContext {
c.mtx.Unlock() c.mtx.Unlock()
log := c.opts.log.With( log := &logger.Logger{Logger: c.opts.log.With(
zap.Uint64("epoch", epoch), zap.Uint64("epoch", epoch),
) )}
if ctx == nil { if ctx == nil {
log.Debug("report is already started") log.Debug("report is already started")
@ -191,6 +191,6 @@ func (p *StopPrm) SetEpoch(e uint64) {
func (c *Controller) Stop(prm StopPrm) { func (c *Controller) Stop(prm StopPrm) {
c.freeReport( c.freeReport(
prm.epoch, prm.epoch,
c.opts.log.With(zap.Uint64("epoch", prm.epoch)), &logger.Logger{Logger: c.opts.log.With(zap.Uint64("epoch", prm.epoch))},
) )
} }

View file

@ -14,7 +14,7 @@ type options struct {
func defaultOpts() *options { func defaultOpts() *options {
return &options{ return &options{
log: zap.L(), log: &logger.Logger{Logger: zap.L()},
} }
} }

View file

@ -4,11 +4,12 @@ import (
"crypto/ecdsa" "crypto/ecdsa"
"time" "time"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"go.uber.org/zap" "go.uber.org/zap"
) )
type cfg struct { type cfg struct {
l *zap.Logger l *logger.Logger
timeout time.Duration timeout time.Duration
privateKey *ecdsa.PrivateKey privateKey *ecdsa.PrivateKey
} }
@ -18,14 +19,14 @@ type Option func(*cfg)
func defaultCfg() *cfg { func defaultCfg() *cfg {
return &cfg{ return &cfg{
l: zap.L(), l: &logger.Logger{Logger: zap.L()},
timeout: 100 * time.Millisecond, timeout: 100 * time.Millisecond,
} }
} }
// WithLogger returns an option to specify // WithLogger returns an option to specify
// logger. // logger.
func WithLogger(v *zap.Logger) Option { func WithLogger(v *logger.Logger) Option {
return func(c *cfg) { return func(c *cfg) {
c.l = v c.l = v
} }

View file

@ -7,6 +7,7 @@ import (
"fmt" "fmt"
"github.com/nspcc-dev/neofs-node/pkg/services/session/storage" "github.com/nspcc-dev/neofs-node/pkg/services/session/storage"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"github.com/nspcc-dev/neofs-sdk-go/user" "github.com/nspcc-dev/neofs-sdk-go/user"
"go.etcd.io/bbolt" "go.etcd.io/bbolt"
"go.uber.org/zap" "go.uber.org/zap"
@ -18,7 +19,7 @@ import (
type TokenStore struct { type TokenStore struct {
db *bbolt.DB db *bbolt.DB
l *zap.Logger l *logger.Logger
// optional AES-256 algorithm // optional AES-256 algorithm
// encryption in Galois/Counter // encryption in Galois/Counter

View file

@ -7,11 +7,11 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/core/container" "github.com/nspcc-dev/neofs-node/pkg/core/container"
"github.com/nspcc-dev/neofs-node/pkg/core/netmap" "github.com/nspcc-dev/neofs-node/pkg/core/netmap"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/pilorama" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/pilorama"
"go.uber.org/zap" "github.com/nspcc-dev/neofs-node/pkg/util/logger"
) )
type cfg struct { type cfg struct {
log *zap.Logger log *logger.Logger
key *ecdsa.PrivateKey key *ecdsa.PrivateKey
rawPub []byte rawPub []byte
nmSource netmap.Source nmSource netmap.Source
@ -61,7 +61,7 @@ func WithPrivateKey(key *ecdsa.PrivateKey) Option {
} }
// WithLogger sets logger for a tree service. // WithLogger sets logger for a tree service.
func WithLogger(log *zap.Logger) Option { func WithLogger(log *logger.Logger) Option {
return func(c *cfg) { return func(c *cfg) {
c.log = log c.log = log
} }

View file

@ -7,6 +7,7 @@ import (
"fmt" "fmt"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/pilorama" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/pilorama"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"github.com/nspcc-dev/neofs-sdk-go/container/acl" "github.com/nspcc-dev/neofs-sdk-go/container/acl"
cidSDK "github.com/nspcc-dev/neofs-sdk-go/container/id" cidSDK "github.com/nspcc-dev/neofs-sdk-go/container/id"
netmapSDK "github.com/nspcc-dev/neofs-sdk-go/netmap" netmapSDK "github.com/nspcc-dev/neofs-sdk-go/netmap"
@ -39,7 +40,7 @@ func New(opts ...Option) *Service {
} }
if s.log == nil { if s.log == nil {
s.log = zap.NewNop() s.log = &logger.Logger{Logger: zap.NewNop()}
} }
s.cache.init() s.cache.init()

View file

@ -10,6 +10,7 @@ import (
aclV2 "github.com/nspcc-dev/neofs-api-go/v2/acl" aclV2 "github.com/nspcc-dev/neofs-api-go/v2/acl"
containercore "github.com/nspcc-dev/neofs-node/pkg/core/container" containercore "github.com/nspcc-dev/neofs-node/pkg/core/container"
"github.com/nspcc-dev/neofs-node/pkg/core/netmap" "github.com/nspcc-dev/neofs-node/pkg/core/netmap"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"github.com/nspcc-dev/neofs-sdk-go/bearer" "github.com/nspcc-dev/neofs-sdk-go/bearer"
"github.com/nspcc-dev/neofs-sdk-go/container" "github.com/nspcc-dev/neofs-sdk-go/container"
"github.com/nspcc-dev/neofs-sdk-go/container/acl" "github.com/nspcc-dev/neofs-sdk-go/container/acl"
@ -70,7 +71,7 @@ func TestMessageSign(t *testing.T) {
s := &Service{ s := &Service{
cfg: cfg{ cfg: cfg{
log: zaptest.NewLogger(t), log: &logger.Logger{Logger: zaptest.NewLogger(t)},
key: &privs[0].PrivateKey, key: &privs[0].PrivateKey,
nmSource: dummyNetmapSource{}, nmSource: dummyNetmapSource{},
cnrSource: dummyContainerSource{ cnrSource: dummyContainerSource{

View file

@ -9,10 +9,10 @@ import (
// Logger represents a component // Logger represents a component
// for writing messages to log. // for writing messages to log.
// type Logger struct {
// It is a type alias of *zap.Logger
// go.uber.org/zap.Logger. lvl zap.AtomicLevel
type Logger = zap.Logger }
// Prm groups Logger's parameters. // Prm groups Logger's parameters.
type Prm struct { type Prm struct {
@ -40,12 +40,19 @@ func (p *Prm) SetLevelString(s string) error {
// //
// Logger records a stack trace for all messages at or above fatal level. // Logger records a stack trace for all messages at or above fatal level.
func NewLogger(prm Prm) (*Logger, error) { func NewLogger(prm Prm) (*Logger, error) {
lvl := zap.NewAtomicLevelAt(prm.level)
c := zap.NewProductionConfig() c := zap.NewProductionConfig()
c.Level = zap.NewAtomicLevelAt(prm.level) c.Level = lvl
c.Encoding = "console" c.Encoding = "console"
c.EncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder c.EncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder
return c.Build( l, err := c.Build(
zap.AddStacktrace(zap.NewAtomicLevelAt(zap.FatalLevel)), zap.AddStacktrace(zap.NewAtomicLevelAt(zap.FatalLevel)),
) )
if err != nil {
return nil, err
}
return &Logger{Logger: l, lvl: lvl}, nil
} }

View file

@ -12,6 +12,9 @@ const sampling = 1000
// //
// If debug, development logger is created. // If debug, development logger is created.
func NewLogger(debug bool) *logger.Logger { func NewLogger(debug bool) *logger.Logger {
var l logger.Logger
l.Logger = zap.L()
if debug { if debug {
cfg := zap.NewDevelopmentConfig() cfg := zap.NewDevelopmentConfig()
cfg.Sampling = &zap.SamplingConfig{ cfg.Sampling = &zap.SamplingConfig{
@ -26,8 +29,8 @@ func NewLogger(debug bool) *logger.Logger {
panic("could not prepare logger: " + err.Error()) panic("could not prepare logger: " + err.Error())
} }
return log l.Logger = log
} }
return zap.L() return &l
} }