[#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
log *zap.Logger
log *logger.Logger
wg *sync.WaitGroup
workers []worker

View file

@ -92,7 +92,7 @@ func serveGRPC(c *cfg) {
}
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...")

View file

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

View file

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

View file

@ -133,7 +133,7 @@ type FinalWriterOption func(*finalWriterOptions)
func defaultFinalWriterOptionsOpts() *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/event"
"github.com/nspcc-dev/neofs-node/pkg/morph/timer"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"go.uber.org/zap"
)
@ -28,7 +29,7 @@ type (
newEpochHandler func()
epochTimerArgs struct {
l *zap.Logger
l *logger.Logger
newEpochHandlers []newEpochHandler

View file

@ -47,6 +47,7 @@ import (
reputationcommon "github.com/nspcc-dev/neofs-node/pkg/services/reputation/common"
util2 "github.com/nspcc-dev/neofs-node/pkg/util"
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/state"
"github.com/panjf2000/ants/v2"
@ -60,7 +61,7 @@ type (
// Server is the inner ring application structure, that contains all event
// processors, shared variables and event handlers.
Server struct {
log *zap.Logger
log *logger.Logger
// event producers
morphListener event.Listener
@ -128,7 +129,7 @@ type (
}
chainParams struct {
log *zap.Logger
log *logger.Logger
cfg *viper.Viper
key *keys.PrivateKey
name string
@ -316,7 +317,7 @@ func (s *Server) registerStarter(f func() error) {
}
// 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
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{
Logger: p.log.With(zap.String("chain", p.name)),
Logger: &logger.Logger{Logger: p.log.With(zap.String("chain", p.name))},
Subscriber: sub,
WorkerPoolCapacity: listenerPoolCap,
})

View file

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

View file

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

View file

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

View file

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

View file

@ -12,8 +12,8 @@ import (
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/rolemanagement"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"github.com/panjf2000/ants/v2"
"go.uber.org/zap"
)
// 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 struct {
log *zap.Logger
log *logger.Logger
pool *ants.Pool
neofsClient *neofscontract.Client
netmapClient *nmClient.Client
@ -75,7 +75,7 @@ type (
// Params of the processor constructor.
Params struct {
Log *zap.Logger
Log *logger.Logger
AlphabetState AlphabetState
EpochState EpochState

View file

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

View file

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

View file

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

View file

@ -53,9 +53,9 @@ var (
// 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.
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),
)
)}
if p.Epoch == 0 {
log.Info("settlements are ignored for zero epoch")
@ -104,10 +104,10 @@ func (c *Calculator) Calculate(p *CalculatePrm) {
}
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.Uint64("audit epoch", ctx.auditResult.Epoch()),
)
)}
ctx.log.Debug("reading information about the container")

View file

@ -22,7 +22,7 @@ type options struct {
func defaultOptions() *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/neofs-node/pkg/innerring/processors/settlement/common"
"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"
"go.uber.org/zap"
)
type (
@ -28,7 +28,7 @@ type (
IncomeSettlementContext struct {
mu sync.Mutex // lock to prevent collection and distribution in the same time
log *zap.Logger
log *logger.Logger
epoch uint64
rate RateFetcher
@ -46,7 +46,7 @@ type (
}
IncomeSettlementContextPrms struct {
Log *zap.Logger
Log *logger.Logger
Epoch uint64
Rate RateFetcher
Estimations EstimationFetcher

View file

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

View file

@ -19,7 +19,7 @@ func defaultOptions() *options {
return &options{
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/services/audit/auditor"
"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"
"github.com/nspcc-dev/neofs-sdk-go/netmap"
"github.com/nspcc-dev/neofs-sdk-go/object"
@ -23,7 +24,7 @@ import (
type (
ClientCache struct {
log *zap.Logger
log *logger.Logger
cache interface {
Get(clientcore.NodeInfo) (clientcore.Client, error)
CloseAll()
@ -34,7 +35,7 @@ type (
}
clientCacheParams struct {
Log *zap.Logger
Log *logger.Logger
Key *ecdsa.PrivateKey
AllowExternal bool

View file

@ -51,7 +51,7 @@ func defaultCfg(с *cfg) {
},
fullSizeLimit: 1 << 30, // 1GB
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.
func WithLogger(l *logger.Logger) Option {
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/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/util/logger"
"github.com/nspcc-dev/neofs-node/pkg/util/logger/test"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
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("", "*")
require.NoError(t, err)
b := NewBlobovniczaTree(
WithLogger(zaptest.NewLogger(t)),
WithLogger(&logger.Logger{Logger: zaptest.NewLogger(t)}),
WithObjectSizeLimit(2048),
WithBlobovniczaShallowWidth(3),
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/internal/blobstortest"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"go.uber.org/zap/zaptest"
)
@ -18,7 +19,7 @@ func TestGeneric(t *testing.T) {
helper := func(t *testing.T, dir string) common.Storage {
return NewBlobovniczaTree(
WithLogger(zaptest.NewLogger(t)),
WithLogger(&logger.Logger{Logger: zaptest.NewLogger(t)}),
WithObjectSizeLimit(maxObjectSize),
WithBlobovniczaShallowWidth(2),
WithBlobovniczaShallowDepth(2),
@ -51,7 +52,7 @@ func TestControl(t *testing.T) {
newTree := func(t *testing.T) common.Storage {
dir := filepath.Join(t.Name(), strconv.Itoa(n))
return NewBlobovniczaTree(
WithLogger(zaptest.NewLogger(t)),
WithLogger(&logger.Logger{Logger: zaptest.NewLogger(t)}),
WithObjectSizeLimit(maxObjectSize),
WithBlobovniczaShallowWidth(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/blobstor/compression"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"go.uber.org/zap"
)
type cfg struct {
log *zap.Logger
log *logger.Logger
perm fs.FileMode
readOnly bool
rootPath string
@ -31,7 +32,7 @@ const (
func initConfig(c *cfg) {
*c = cfg{
log: zap.L(),
log: &logger.Logger{Logger: zap.L()},
perm: defaultPerm,
openedCacheSize: defaultOpenedCacheSize,
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) {
c.log = l
c.blzOpts = append(c.blzOpts, blobovnicza.WithLogger(l))

View file

@ -46,7 +46,7 @@ type cfg struct {
}
func initConfig(c *cfg) {
c.log = zap.L()
c.log = &logger.Logger{Logger: zap.L()}
}
// 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.
func (b *BlobStor) SetLogger(l *zap.Logger) {
func (b *BlobStor) SetLogger(l *logger.Logger) {
b.log = l
}
@ -80,7 +80,7 @@ func WithStorages(st []SubStorage) Option {
// WithLogger returns option to specify BlobStor's logger.
func WithLogger(l *logger.Logger) Option {
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"
"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"
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
@ -52,7 +53,7 @@ func TestDeleteBigObject(t *testing.T) {
s3 := testNewShard(t, 3)
e := testNewEngineWithShards(s1, s2, s3)
e.log = zaptest.NewLogger(t)
e.log = &logger.Logger{Logger: zaptest.NewLogger(t)}
defer e.Close()
for i := range children {

View file

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

View file

@ -12,6 +12,7 @@ import (
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/shard"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"github.com/nspcc-dev/neofs-sdk-go/checksum"
checksumtest "github.com/nspcc-dev/neofs-sdk-go/checksum/test"
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(
shard.WithID(sid),
shard.WithLogger(zap.L()),
shard.WithLogger(&logger.Logger{Logger: zap.L()}),
shard.WithBlobStorOptions(
blobstor.WithStorages(
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/shard"
"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"
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
@ -32,7 +33,7 @@ func newEngineWithErrorThreshold(t testing.TB, dir string, errThreshold uint32)
}
e := New(
WithLogger(zaptest.NewLogger(t)),
WithLogger(&logger.Logger{Logger: zaptest.NewLogger(t)}),
WithShardPoolSize(1),
WithErrorThreshold(errThreshold))
@ -41,7 +42,7 @@ func newEngineWithErrorThreshold(t testing.TB, dir string, errThreshold uint32)
for i := range ids {
ids[i], err = e.AddShard(
shard.WithLogger(zaptest.NewLogger(t)),
shard.WithLogger(&logger.Logger{Logger: zaptest.NewLogger(t)}),
shard.WithBlobStorOptions(
blobstor.WithStorages(newStorages(filepath.Join(dir, strconv.Itoa(i)), errSmallSize))),
shard.WithMetaBaseOptions(

View file

@ -14,6 +14,7 @@ import (
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/mode"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
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) })
e := New(
WithLogger(zaptest.NewLogger(t)),
WithLogger(&logger.Logger{Logger: zaptest.NewLogger(t)}),
WithShardPoolSize(1))
ids := make([]*shard.ID, shardNum)
for i := range ids {
ids[i], err = e.AddShard(
shard.WithLogger(zaptest.NewLogger(t)),
shard.WithLogger(&logger.Logger{Logger: zaptest.NewLogger(t)}),
shard.WithBlobStorOptions(
blobstor.WithStorages([]blobstor.SubStorage{{
Storage: fstree.New(

View file

@ -69,7 +69,7 @@ func defaultCfg() *cfg {
},
boltBatchDelay: bbolt.DefaultMaxBatchDelay,
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.
func (db *DB) SetLogger(l *zap.Logger) {
func (db *DB) SetLogger(l *logger.Logger) {
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/shard/mode"
"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"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
@ -36,7 +37,7 @@ func TestShardOpen(t *testing.T) {
newShard := func() *Shard {
return New(
WithLogger(zaptest.NewLogger(t)),
WithLogger(&logger.Logger{Logger: zaptest.NewLogger(t)}),
WithBlobStorOptions(
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/mode"
"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"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
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.WithSmallObjectSize(wcSmallObjectSize),
writecache.WithMaxObjectSize(wcBigObjectSize),
writecache.WithLogger(zaptest.NewLogger(t)),
writecache.WithLogger(&logger.Logger{Logger: zaptest.NewLogger(t)}),
},
nil)
}

View file

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

View file

@ -2,6 +2,7 @@ package shard
import (
"github.com/mr-tron/base58"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"go.uber.org/zap"
)
@ -44,7 +45,7 @@ func (s *Shard) UpdateID() (err error) {
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.blobStor.SetLogger(s.log)
if s.hasWriteCache() {

View file

@ -11,6 +11,7 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/fstree"
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/util/logger"
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
"github.com/nspcc-dev/neofs-sdk-go/object"
@ -24,7 +25,7 @@ func TestShard_Lock(t *testing.T) {
rootPath := t.TempDir()
opts := []shard.Option{
shard.WithLogger(zap.NewNop()),
shard.WithLogger(&logger.Logger{Logger: zap.NewNop()}),
shard.WithBlobStorOptions(
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/shard"
"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"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
"github.com/stretchr/testify/require"
@ -69,7 +70,7 @@ func testShardGetRange(t *testing.T, hasWriteCache bool) {
[]blobstor.Option{blobstor.WithStorages([]blobstor.SubStorage{
{
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.WithBlobovniczaShallowDepth(1),
blobovniczatree.WithBlobovniczaShallowWidth(1)),

View file

@ -98,7 +98,7 @@ type cfg struct {
func defaultCfg() *cfg {
return &cfg{
rmBatchSize: 100,
log: zap.L(),
log: &logger.Logger{Logger: zap.L()},
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/shard"
"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"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
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 {
bsOpts = []blobstor.Option{
blobstor.WithLogger(zaptest.NewLogger(t)),
blobstor.WithLogger(&logger.Logger{Logger: zaptest.NewLogger(t)}),
blobstor.WithStorages([]blobstor.SubStorage{
{
Storage: blobovniczatree.NewBlobovniczaTree(
blobovniczatree.WithLogger(zaptest.NewLogger(t)),
blobovniczatree.WithLogger(&logger.Logger{Logger: zaptest.NewLogger(t)}),
blobovniczatree.WithRootPath(filepath.Join(rootPath, "blob", "blobovnicza")),
blobovniczatree.WithBlobovniczaShallowDepth(1),
blobovniczatree.WithBlobovniczaShallowWidth(1)),
@ -68,7 +69,7 @@ func newCustomShard(t testing.TB, rootPath string, enableWriteCache bool, wcOpts
}
opts := []shard.Option{
shard.WithLogger(zap.L()),
shard.WithLogger(&logger.Logger{Logger: zap.L()}),
shard.WithBlobStorOptions(bsOpts...),
shard.WithMetaBaseOptions(
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"
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/util/logger"
checksumtest "github.com/nspcc-dev/neofs-sdk-go/checksum/test"
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
"github.com/nspcc-dev/neofs-sdk-go/object"
@ -53,7 +54,7 @@ func TestFlush(t *testing.T) {
require.NoError(t, bs.Init())
wc := New(
WithLogger(zaptest.NewLogger(t)),
WithLogger(&logger.Logger{Logger: zaptest.NewLogger(t)}),
WithPath(filepath.Join(dir, "writecache")),
WithSmallObjectSize(smallSize),
WithMetabase(mb),

View file

@ -7,6 +7,7 @@ import (
"testing"
"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"
"go.uber.org/zap/zaptest"
)
@ -20,7 +21,7 @@ func TestGeneric(t *testing.T) {
dir := filepath.Join(t.Name(), strconv.Itoa(n))
require.NoError(t, os.MkdirAll(dir, os.ModePerm))
return New(
WithLogger(zaptest.NewLogger(t)),
WithLogger(&logger.Logger{Logger: zaptest.NewLogger(t)}),
WithFlushWorkersCount(2),
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/common"
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"
"go.uber.org/zap"
)
@ -27,7 +28,7 @@ type blob interface {
}
type options struct {
log *zap.Logger
log *logger.Logger
// path is a path to a directory for write-cache.
path string
// blobstor is the main persistent storage.
@ -52,9 +53,9 @@ type options struct {
}
// WithLogger sets logger.
func WithLogger(log *zap.Logger) Option {
func WithLogger(log *logger.Logger) Option {
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/fstree"
"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"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
"go.etcd.io/bbolt"
@ -26,7 +27,7 @@ type Cache interface {
Iterate(IterationPrm) error
Put(common.PutPrm) (common.PutRes, error)
SetMode(mode.Mode) error
SetLogger(*zap.Logger)
SetLogger(*logger.Logger)
DumpInfo() Info
Flush(bool) error
@ -84,7 +85,7 @@ func New(opts ...Option) Cache {
compressFlags: make(map[string]struct{}),
options: options{
log: zap.NewNop(),
log: &logger.Logger{Logger: zap.NewNop()},
maxObjectSize: defaultMaxObjectSize,
smallObjectSize: defaultSmallObjectSize,
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.
func (c *cache) SetLogger(l *zap.Logger) {
func (c *cache) SetLogger(l *logger.Logger) {
c.log = l
}

View file

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

View file

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

View file

@ -10,6 +10,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
util2 "github.com/nspcc-dev/neofs-node/pkg/util"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"go.uber.org/zap"
)
@ -81,7 +82,7 @@ func (s typeValue) GetType() Type {
}
// 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) {
err := w.Submit(func() {
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/util"
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"go.uber.org/zap"
)
@ -27,7 +28,7 @@ type (
subscriber struct {
*sync.RWMutex
log *zap.Logger
log *logger.Logger
client *client.Client
notifyChan chan *state.ContainedNotificationEvent
@ -39,7 +40,7 @@ type (
// Params is a group of Subscriber constructor parameters.
Params struct {
Log *zap.Logger
Log *logger.Logger
StartFromBlock uint32
Client *client.Client
}

View file

@ -191,9 +191,9 @@ func (c *Context) init() {
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()),
)
)}
}
func (c *Context) expired() bool {

View file

@ -34,7 +34,7 @@ type cfg struct {
func defaultCfg() *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.
func WithLogger(l *logger.Logger) Option {
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)
}
}

View file

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

View file

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

View file

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

View file

@ -4,7 +4,7 @@ import (
"time"
"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 {
@ -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) {
o.log = logger
}

View file

@ -7,6 +7,7 @@ import (
"sync"
"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"
"go.uber.org/zap"
)
@ -29,7 +30,7 @@ type Writer struct {
}
type opts struct {
log *zap.Logger
log *logger.Logger
nOpts []nats.Option
}
@ -85,7 +86,7 @@ func New(oo ...Option) *Writer {
m: &sync.RWMutex{},
createdStreams: make(map[string]struct{}),
opts: opts{
log: zap.L(),
log: &logger.Logger{Logger: zap.L()},
nOpts: make([]nats.Option, 0, len(oo)+3),
},
}

View file

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

View file

@ -5,6 +5,7 @@ import (
"crypto/sha256"
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/acl"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
@ -13,7 +14,7 @@ import (
)
type senderClassifier struct {
log *zap.Logger
log *logger.Logger
innerRing InnerRingFetcher
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/netmap"
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.
func WithLogger(v *zap.Logger) Option {
func WithLogger(v *logger.Logger) Option {
return func(c *cfg) {
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/netmap"
"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"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
@ -57,7 +58,7 @@ type searchStreamBasicChecker struct {
type Option func(*cfg)
type cfg struct {
log *zap.Logger
log *logger.Logger
containers container.Source
@ -72,7 +73,7 @@ type cfg struct {
func defaultCfg() *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) {
exec.log = l.With(
exec.log = &logger.Logger{Logger: l.With(
zap.String("request", "DELETE"),
zap.Stringer("address", exec.address()),
zap.Bool("local", exec.isLocal()),
zap.Bool("with session", exec.prm.common.SessionToken() != nil),
zap.Bool("with bearer", exec.prm.common.BearerToken() != nil),
)
)}
}
func (exec execCtx) context() context.Context {

View file

@ -62,7 +62,7 @@ type cfg struct {
func defaultCfg() *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.
func WithLogger(l *logger.Logger) Option {
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"
}
exec.log = l.With(
exec.log = &logger.Logger{Logger: l.With(
zap.String("request", req),
zap.Stringer("address", exec.address()),
zap.Bool("raw", exec.isRaw()),
zap.Bool("local", exec.isLocal()),
zap.Bool("with session", exec.prm.common.SessionToken() != nil),
zap.Bool("with bearer", exec.prm.common.BearerToken() != nil),
)
)}
}
func (exec execCtx) context() context.Context {

View file

@ -52,7 +52,7 @@ type cfg struct {
func defaultCfg() *cfg {
return &cfg{
assembly: true,
log: zap.L(),
log: &logger.Logger{Logger: zap.L()},
localStorage: new(storageEngineWrapper),
clientCache: new(clientCacheWrapper),
}
@ -75,7 +75,7 @@ func New(opts ...Option) *Service {
// WithLogger returns option to specify Get service's logger.
func WithLogger(l *logger.Logger) Option {
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{
remotePool: 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) {
exec.log = l.With(
exec.log = &logger.Logger{Logger: l.With(
zap.String("request", "SEARCH"),
zap.Stringer("container", exec.containerID()),
zap.Bool("local", exec.isLocal()),
zap.Bool("with session", exec.prm.common.SessionToken() != nil),
zap.Bool("with bearer", exec.prm.common.BearerToken() != nil),
)
)}
}
func (exec execCtx) context() context.Context {

View file

@ -55,7 +55,7 @@ type cfg struct {
func defaultCfg() *cfg {
return &cfg{
log: zap.L(),
log: &logger.Logger{Logger: zap.L()},
clientConstructor: new(clientConstructorWrapper),
}
}
@ -77,7 +77,7 @@ func New(opts ...Option) *Service {
// WithLogger returns option to specify Get service's logger.
func WithLogger(l *logger.Logger) Option {
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"
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"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
"go.uber.org/zap"
@ -32,7 +33,7 @@ type Source interface {
type ExpirationChecker struct {
cache *lru.Cache
log *zap.Logger
log *logger.Logger
tsSource Source
}

View file

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

View file

@ -97,7 +97,7 @@ type cfg struct {
func defaultCfg() *cfg {
return &cfg{
log: zap.L(),
log: &logger.Logger{Logger: zap.L()},
batchSize: 10,
cacheSize: 200_000, // should not allocate more than 200 MiB
rebalanceFreq: 1 * time.Second,
@ -113,7 +113,7 @@ func New(opts ...Option) *Policer {
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))
if err != nil {

View file

@ -40,7 +40,7 @@ func New(opts ...Option) *Replicator {
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{
cfg: c,

View file

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

View file

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

View file

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

View file

@ -14,7 +14,7 @@ type options struct {
func defaultOpts() *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()
log := c.opts.log.With(
log := &logger.Logger{Logger: c.opts.log.With(
zap.Uint64("epoch", epoch),
)
)}
if ctx == nil {
log.Debug("report is already started")
@ -191,6 +191,6 @@ func (p *StopPrm) SetEpoch(e uint64) {
func (c *Controller) Stop(prm StopPrm) {
c.freeReport(
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 {
return &options{
log: zap.L(),
log: &logger.Logger{Logger: zap.L()},
}
}

View file

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

View file

@ -7,6 +7,7 @@ import (
"fmt"
"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"
"go.etcd.io/bbolt"
"go.uber.org/zap"
@ -18,7 +19,7 @@ import (
type TokenStore struct {
db *bbolt.DB
l *zap.Logger
l *logger.Logger
// optional AES-256 algorithm
// 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/netmap"
"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 {
log *zap.Logger
log *logger.Logger
key *ecdsa.PrivateKey
rawPub []byte
nmSource netmap.Source
@ -61,7 +61,7 @@ func WithPrivateKey(key *ecdsa.PrivateKey) Option {
}
// WithLogger sets logger for a tree service.
func WithLogger(log *zap.Logger) Option {
func WithLogger(log *logger.Logger) Option {
return func(c *cfg) {
c.log = log
}

View file

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

View file

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

View file

@ -9,10 +9,10 @@ import (
// Logger represents a component
// for writing messages to log.
//
// It is a type alias of
// go.uber.org/zap.Logger.
type Logger = zap.Logger
type Logger struct {
*zap.Logger
lvl zap.AtomicLevel
}
// Prm groups Logger's parameters.
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.
func NewLogger(prm Prm) (*Logger, error) {
lvl := zap.NewAtomicLevelAt(prm.level)
c := zap.NewProductionConfig()
c.Level = zap.NewAtomicLevelAt(prm.level)
c.Level = lvl
c.Encoding = "console"
c.EncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder
return c.Build(
l, err := c.Build(
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.
func NewLogger(debug bool) *logger.Logger {
var l logger.Logger
l.Logger = zap.L()
if debug {
cfg := zap.NewDevelopmentConfig()
cfg.Sampling = &zap.SamplingConfig{
@ -26,8 +29,8 @@ func NewLogger(debug bool) *logger.Logger {
panic("could not prepare logger: " + err.Error())
}
return log
l.Logger = log
}
return zap.L()
return &l
}