From f85e02714176531a76b84a69fa6fff07e9987d03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Kapka?= Date: Wed, 21 Feb 2024 18:34:57 +0100 Subject: [PATCH] Normalize filesystem/blob logs (#13644) --- beacon-chain/db/filesystem/BUILD.bazel | 1 + beacon-chain/db/filesystem/blob.go | 10 +++++----- beacon-chain/db/filesystem/log.go | 5 +++++ beacon-chain/db/filesystem/pruner.go | 4 ++-- 4 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 beacon-chain/db/filesystem/log.go diff --git a/beacon-chain/db/filesystem/BUILD.bazel b/beacon-chain/db/filesystem/BUILD.bazel index f9b0c8ca6..9095da42e 100644 --- a/beacon-chain/db/filesystem/BUILD.bazel +++ b/beacon-chain/db/filesystem/BUILD.bazel @@ -5,6 +5,7 @@ go_library( srcs = [ "blob.go", "ephemeral.go", + "log.go", "metrics.go", "pruner.go", ], diff --git a/beacon-chain/db/filesystem/blob.go b/beacon-chain/db/filesystem/blob.go index d081af8ea..1f9d3b5db 100644 --- a/beacon-chain/db/filesystem/blob.go +++ b/beacon-chain/db/filesystem/blob.go @@ -16,7 +16,7 @@ import ( "github.com/prysmaticlabs/prysm/v5/io/file" ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/v5/runtime/logging" - log "github.com/sirupsen/logrus" + "github.com/sirupsen/logrus" "github.com/spf13/afero" ) @@ -83,7 +83,7 @@ func (bs *BlobStorage) WarmCache() { } go func() { if err := bs.pruner.prune(0); err != nil { - log.WithError(err).Error("Error encountered while warming up blob pruner cache.") + log.WithError(err).Error("Error encountered while warming up blob pruner cache") } }() } @@ -98,7 +98,7 @@ func (bs *BlobStorage) Save(sidecar blocks.VerifiedROBlob) error { return err } if exists { - log.WithFields(logging.BlobFields(sidecar.ROBlob)).Debug("ignoring a duplicate blob sidecar Save attempt") + log.WithFields(logging.BlobFields(sidecar.ROBlob)).Debug("Ignoring a duplicate blob sidecar save attempt") return nil } if bs.pruner != nil { @@ -126,9 +126,9 @@ func (bs *BlobStorage) Save(sidecar blocks.VerifiedROBlob) error { // It's expected to error if the save is successful. err = bs.fs.Remove(partPath) if err == nil { - log.WithFields(log.Fields{ + log.WithFields(logrus.Fields{ "partPath": partPath, - }).Debugf("removed partial file") + }).Debugf("Removed partial file") } }() diff --git a/beacon-chain/db/filesystem/log.go b/beacon-chain/db/filesystem/log.go new file mode 100644 index 000000000..8a85d549c --- /dev/null +++ b/beacon-chain/db/filesystem/log.go @@ -0,0 +1,5 @@ +package filesystem + +import "github.com/sirupsen/logrus" + +var log = logrus.WithField("prefix", "filesystem") diff --git a/beacon-chain/db/filesystem/pruner.go b/beacon-chain/db/filesystem/pruner.go index 5c349d843..2a1dff821 100644 --- a/beacon-chain/db/filesystem/pruner.go +++ b/beacon-chain/db/filesystem/pruner.go @@ -16,7 +16,7 @@ import ( "github.com/prysmaticlabs/prysm/v5/config/params" "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" "github.com/prysmaticlabs/prysm/v5/time/slots" - log "github.com/sirupsen/logrus" + "github.com/sirupsen/logrus" "github.com/spf13/afero" ) @@ -87,7 +87,7 @@ func (p *blobPruner) prune(pruneBefore primitives.Slot) error { }() } else { defer func() { - log.WithFields(log.Fields{ + log.WithFields(logrus.Fields{ "upToEpoch": slots.ToEpoch(pruneBefore), "duration": time.Since(start).String(), "filesRemoved": totalPruned,