diff --git a/cmd/frostfs-node/morph.go b/cmd/frostfs-node/morph.go index 657e22389..532c530db 100644 --- a/cmd/frostfs-node/morph.go +++ b/cmd/frostfs-node/morph.go @@ -14,6 +14,7 @@ import ( "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/event" netmapEvent "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/event/netmap" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/subscriber" + "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/rand" "github.com/nspcc-dev/neo-go/pkg/core/block" "github.com/nspcc-dev/neo-go/pkg/core/state" @@ -172,14 +173,14 @@ func listenMorphNotifications(ctx context.Context, c *cfg) { } subs, err = subscriber.New(ctx, &subscriber.Params{ - Log: c.log, + Log: c.log.WithTag(logger.TagMorph), StartFromBlock: fromSideChainBlock, Client: c.cfgMorph.client, }) fatalOnErr(err) lis, err := event.NewListener(event.ListenerParams{ - Logger: c.log, + Logger: c.log.WithTag(logger.TagMorph), Subscriber: subs, }) fatalOnErr(err) diff --git a/config/example/node.env b/config/example/node.env index 2ba432b1b..9dcb49aca 100644 --- a/config/example/node.env +++ b/config/example/node.env @@ -1,6 +1,7 @@ FROSTFS_LOGGER_LEVEL=debug FROSTFS_LOGGER_DESTINATION=journald FROSTFS_LOGGER_TIMESTAMP=true +FROSTFS_LOGGER_ALLOWED_TAGS="main:debug" FROSTFS_PPROF_ENABLED=true FROSTFS_PPROF_ADDRESS=localhost:6060 diff --git a/config/example/node.json b/config/example/node.json index cfde8bcc7..1a7eabd02 100644 --- a/config/example/node.json +++ b/config/example/node.json @@ -2,7 +2,8 @@ "logger": { "level": "debug", "destination": "journald", - "timestamp": true + "timestamp": true, + "allowed_tags": ["main:debug"] }, "pprof": { "enabled": true, diff --git a/config/example/node.yaml b/config/example/node.yaml index 1f8ec843d..e2d86a145 100644 --- a/config/example/node.yaml +++ b/config/example/node.yaml @@ -2,6 +2,8 @@ logger: level: debug # logger level: one of "debug", "info" (default), "warn", "error", "dpanic", "panic", "fatal" destination: journald # logger destination: one of "stdout" (default), "journald" timestamp: true + allowed_tags: + - "main:debug" systemdnotify: enabled: true diff --git a/docs/storage-node-configuration.md b/docs/storage-node-configuration.md index de2729c68..911efedc9 100644 --- a/docs/storage-node-configuration.md +++ b/docs/storage-node-configuration.md @@ -113,9 +113,10 @@ logger: level: info ``` -| Parameter | Type | Default value | Description | -|-----------|----------|---------------|---------------------------------------------------------------------------------------------------| -| `level` | `string` | `info` | Logging level.
Possible values: `debug`, `info`, `warn`, `error`, `dpanic`, `panic`, `fatal` | +| Parameter | Type | Default value | Description | +|----------------|------------|---------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `level` | `string` | `info` | Logging level.
Possible values: `debug`, `info`, `warn`, `error`, `dpanic`, `panic`, `fatal` | +| `allowed_tags` | `[]string` | | List of components allowed to produce log entries. Can be combined with logging level: `main:debug`. The resulting level for tag will be the most restrictive.
Possible values: `main`, `morph`, `engine`, `blobovnicza`, `blobstor`, `fstree`, `gc`, `shard`, `writecache`, `deletesvc`, `getsvc`, `searchsvc`, `policer`, `replicator`. | # `contracts` section Contains override values for FrostFS side-chain contract hashes. Most of the time contract diff --git a/pkg/local_object_storage/blobovnicza/blobovnicza.go b/pkg/local_object_storage/blobovnicza/blobovnicza.go index 08ef8b86c..df5222569 100644 --- a/pkg/local_object_storage/blobovnicza/blobovnicza.go +++ b/pkg/local_object_storage/blobovnicza/blobovnicza.go @@ -110,7 +110,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 = l.With(zap.String("component", "Blobovnicza")).WithTag(logger.TagBlobovnicza) } } diff --git a/pkg/local_object_storage/blobstor/blobstor.go b/pkg/local_object_storage/blobstor/blobstor.go index f850f48b4..5003b4ac7 100644 --- a/pkg/local_object_storage/blobstor/blobstor.go +++ b/pkg/local_object_storage/blobstor/blobstor.go @@ -91,7 +91,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 = l.With(zap.String("component", "BlobStor")).WithTag(logger.TagBlobstor) } } diff --git a/pkg/local_object_storage/blobstor/fstree/option.go b/pkg/local_object_storage/blobstor/fstree/option.go index 7155ddcbb..74a5b3ce1 100644 --- a/pkg/local_object_storage/blobstor/fstree/option.go +++ b/pkg/local_object_storage/blobstor/fstree/option.go @@ -53,6 +53,6 @@ func WithFileCounter(c FileCounter) Option { func WithLogger(l *logger.Logger) Option { return func(f *FSTree) { - f.log = l.With(zap.String("component", "FSTree")) + f.log = l.With(zap.String("component", "FSTree")).WithTag(logger.TagFSTree) } } diff --git a/pkg/local_object_storage/engine/engine.go b/pkg/local_object_storage/engine/engine.go index 85652b3ae..8ddc5825a 100644 --- a/pkg/local_object_storage/engine/engine.go +++ b/pkg/local_object_storage/engine/engine.go @@ -227,7 +227,7 @@ func New(opts ...Option) *StorageEngine { // WithLogger returns option to set StorageEngine's logger. func WithLogger(l *logger.Logger) Option { return func(c *cfg) { - c.log = l + c.log = l.WithTag(logger.TagEngine) } } diff --git a/pkg/local_object_storage/shard/gc.go b/pkg/local_object_storage/shard/gc.go index 4a5ec7a71..38a600ab9 100644 --- a/pkg/local_object_storage/shard/gc.go +++ b/pkg/local_object_storage/shard/gc.go @@ -473,7 +473,7 @@ func (s *Shard) collectExpiredTombstones(ctx context.Context, e Event) { }() epoch := e.(newEpoch).epoch - log := s.log.With(zap.Uint64("epoch", epoch)) + log := s.log.With(zap.Uint64("epoch", epoch)).WithTag(logger.TagGC) log.Debug(ctx, logs.ShardStartedExpiredTombstonesHandling) defer log.Debug(ctx, logs.ShardFinishedExpiredTombstonesHandling) diff --git a/pkg/local_object_storage/shard/shard.go b/pkg/local_object_storage/shard/shard.go index 1eb7f14d0..a97cfff41 100644 --- a/pkg/local_object_storage/shard/shard.go +++ b/pkg/local_object_storage/shard/shard.go @@ -200,8 +200,8 @@ func WithPiloramaOptions(opts ...pilorama.Option) Option { // WithLogger returns option to set Shard's logger. func WithLogger(l *logger.Logger) Option { return func(c *cfg) { - c.log = l - c.gcCfg.log = l + c.log = l.WithTag(logger.TagShard) + c.gcCfg.log = l.WithTag(logger.TagGC) } } diff --git a/pkg/local_object_storage/writecache/options.go b/pkg/local_object_storage/writecache/options.go index f2957fe98..deef0ebf4 100644 --- a/pkg/local_object_storage/writecache/options.go +++ b/pkg/local_object_storage/writecache/options.go @@ -43,7 +43,7 @@ type options struct { // WithLogger sets logger. func WithLogger(log *logger.Logger) Option { return func(o *options) { - o.log = log.With(zap.String("component", "WriteCache")) + o.log = log.With(zap.String("component", "WriteCache")).WithTag(logger.TagWriteCache) } } diff --git a/pkg/services/object/delete/service.go b/pkg/services/object/delete/service.go index 867d3f4ef..493d030be 100644 --- a/pkg/services/object/delete/service.go +++ b/pkg/services/object/delete/service.go @@ -92,6 +92,6 @@ func New(gs *getsvc.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", "objectSDK.Delete service")) + c.log = l.With(zap.String("component", "objectSDK.Delete service")).WithTag(logger.TagDeleteSvc) } } diff --git a/pkg/services/object/get/service.go b/pkg/services/object/get/service.go index 9ec10b5f2..487793eb6 100644 --- a/pkg/services/object/get/service.go +++ b/pkg/services/object/get/service.go @@ -53,6 +53,6 @@ func New( // WithLogger returns option to specify Get service's logger. func WithLogger(l *logger.Logger) Option { return func(s *Service) { - s.log = l.With(zap.String("component", "Object.Get service")) + s.log = l.With(zap.String("component", "Object.Get service")).WithTag(logger.TagGetSvc) } } diff --git a/pkg/services/object/get/v2/service.go b/pkg/services/object/get/v2/service.go index fc483b74b..1bd4a128a 100644 --- a/pkg/services/object/get/v2/service.go +++ b/pkg/services/object/get/v2/service.go @@ -145,6 +145,6 @@ func (s *Service) Head(ctx context.Context, req *objectV2.HeadRequest) (*objectV func WithLogger(l *logger.Logger) Option { return func(c *cfg) { - c.log = l.With(zap.String("component", "Object.Get V2 service")) + c.log = l.With(zap.String("component", "Object.Get V2 service")).WithTag(logger.TagGetSvc) } } diff --git a/pkg/services/object/search/service.go b/pkg/services/object/search/service.go index e1aeca957..1c680553d 100644 --- a/pkg/services/object/search/service.go +++ b/pkg/services/object/search/service.go @@ -94,6 +94,6 @@ func New(e *engine.StorageEngine, // 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 = l.With(zap.String("component", "Object.Search service")).WithTag(logger.TagSearchSvc) } } diff --git a/pkg/services/policer/policer.go b/pkg/services/policer/policer.go index 4e8bacfec..c66674a24 100644 --- a/pkg/services/policer/policer.go +++ b/pkg/services/policer/policer.go @@ -4,6 +4,7 @@ import ( "sync" "time" + "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger" oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id" lru "github.com/hashicorp/golang-lru/v2" "go.uber.org/zap" @@ -54,7 +55,7 @@ func New(opts ...Option) *Policer { opts[i](c) } - c.log = c.log.With(zap.String("component", "Object Policer")) + c.log = c.log.With(zap.String("component", "Object Policer")).WithTag(logger.TagPolicer) cache, err := lru.New[oid.Address, time.Time](int(c.cacheSize)) if err != nil { diff --git a/pkg/services/replicator/replicator.go b/pkg/services/replicator/replicator.go index 6910fa5af..3b8231234 100644 --- a/pkg/services/replicator/replicator.go +++ b/pkg/services/replicator/replicator.go @@ -45,7 +45,7 @@ func New(opts ...Option) *Replicator { opts[i](c) } - c.log = c.log.With(zap.String("component", "Object Replicator")) + c.log = c.log.With(zap.String("component", "Object Replicator")).WithTag(logger.TagReplicator) return &Replicator{ cfg: c, diff --git a/pkg/util/logger/allowed_tags.go b/pkg/util/logger/allowed_tags.go index d151b320d..63754fc48 100644 --- a/pkg/util/logger/allowed_tags.go +++ b/pkg/util/logger/allowed_tags.go @@ -14,6 +14,18 @@ const ( TagGrpcSvc TagIr TagProcessor + TagEngine + TagBlobovnicza + TagBlobstor + TagFSTree + TagGC + TagShard + TagWriteCache + TagDeleteSvc + TagGetSvc + TagSearchSvc + TagPolicer + TagReplicator ) // tagToMask return bit mask for the tag, encoded in uint32. @@ -27,6 +39,30 @@ func tagToMask(str string) (uint32, error) { return 1 << TagGrpcSvc, nil case "ir": return 1 << TagIr, nil + case "engine": + return 1 << TagEngine, nil + case "blobovnicza": + return 1 << TagBlobovnicza, nil + case "blobstor": + return 1 << TagBlobstor, nil + case "fstree": + return 1 << TagFSTree, nil + case "gc": + return 1 << TagGC, nil + case "shard": + return 1 << TagShard, nil + case "writecache": + return 1 << TagWriteCache, nil + case "deletesvc": + return 1 << TagDeleteSvc, nil + case "getsvc": + return 1 << TagGetSvc, nil + case "searchsvc": + return 1 << TagSearchSvc, nil + case "policer": + return 1 << TagPolicer, nil + case "replicator": + return 1 << TagReplicator, nil case "processor": return 1 << TagProcessor, nil default: