Improve logs (#16075)

**What type of PR is this?**
Other

**What does this PR do? Why is it needed?**
- Added log prefix to the `genesis` package.
- Added log prefix to the `params` package.
- `WithGenesisValidatorsRoot`: Use camelCase for log field param.
- Move `Origin checkpoint found in db` log from WARN to INFO, since it
is the expected behaviour.

**Other notes for review**
Please read commit by commit

**Acknowledgements**

- [x] I have read
[CONTRIBUTING.md](https://github.com/prysmaticlabs/prysm/blob/develop/CONTRIBUTING.md).
- [x] I have included a uniquely named [changelog fragment
file](https://github.com/prysmaticlabs/prysm/blob/develop/CONTRIBUTING.md#maintaining-changelogmd).
- [x] I have added a description to this PR with sufficient context for
reviewers to understand this PR.
This commit is contained in:
Manu NALEPA
2025-11-28 15:34:02 +01:00
committed by GitHub
parent f97622b054
commit 2a23dc7f4a
11 changed files with 27 additions and 12 deletions

View File

@@ -14,6 +14,7 @@ go_library(
"interop.go",
"io_config.go",
"loader.go",
"log.go",
"mainnet_config.go",
"minimal_config.go",
"network_config.go",

View File

@@ -10,8 +10,6 @@ import (
"sync"
"time"
log "github.com/sirupsen/logrus"
fieldparams "github.com/OffchainLabs/prysm/v7/config/fieldparams"
"github.com/OffchainLabs/prysm/v7/consensus-types/primitives"
"github.com/OffchainLabs/prysm/v7/crypto/hash"
@@ -20,6 +18,7 @@ import (
"github.com/OffchainLabs/prysm/v7/runtime/version"
"github.com/ethereum/go-ethereum/common"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
// BeaconChainConfig contains constant configs for node to participate in beacon chain.
@@ -359,7 +358,7 @@ type NetworkScheduleEntry struct {
isFork bool `yaml:"-" json:"-"`
}
func (e NetworkScheduleEntry) LogFields() log.Fields {
func (e NetworkScheduleEntry) LogFields() logrus.Fields {
gvr := BeaconConfig().GenesisValidatorsRoot
root, err := computeForkDataRoot(e.ForkVersion, gvr)
if err != nil {
@@ -367,7 +366,7 @@ func (e NetworkScheduleEntry) LogFields() log.Fields {
WithField("genesisValidatorsRoot", fmt.Sprintf("%#x", gvr)).
WithError(err).Error("Failed to compute fork data root")
}
fields := log.Fields{
fields := logrus.Fields{
"forkVersion": fmt.Sprintf("%#x", e.ForkVersion),
"forkDigest": fmt.Sprintf("%#x", e.ForkDigest),
"maxBlobsPerBlock": e.MaxBlobsPerBlock,

View File

@@ -10,7 +10,6 @@ import (
"github.com/OffchainLabs/prysm/v7/consensus-types/primitives"
"github.com/OffchainLabs/prysm/v7/math"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
"gopkg.in/yaml.v2"
)

5
config/params/log.go Normal file
View File

@@ -0,0 +1,5 @@
package params
import "github.com/sirupsen/logrus"
var log = logrus.WithField("prefix", "params")

View File

@@ -2,8 +2,6 @@ package params
import (
"fmt"
log "github.com/sirupsen/logrus"
)
type Option func(*BeaconChainConfig)
@@ -11,6 +9,6 @@ type Option func(*BeaconChainConfig)
func WithGenesisValidatorsRoot(gvr [32]byte) Option {
return func(cfg *BeaconChainConfig) {
cfg.GenesisValidatorsRoot = gvr
log.WithField("genesis_validators_root", fmt.Sprintf("%#x", gvr)).Info("Setting genesis validators root")
log.WithField("genesisValidatorsRoot", fmt.Sprintf("%#x", gvr)).Info("Setting genesis validators root")
}
}