mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-06 20:13:59 -05:00
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:
@@ -44,7 +44,7 @@ func NewAPIInitializer(beaconNodeHost string) (*APIInitializer, error) {
|
||||
func (dl *APIInitializer) Initialize(ctx context.Context, d db.Database) error {
|
||||
origin, err := d.OriginCheckpointBlockRoot(ctx)
|
||||
if err == nil && origin != params.BeaconConfig().ZeroHash {
|
||||
log.Warnf("Origin checkpoint root %#x found in db, ignoring checkpoint sync flags", origin)
|
||||
log.WithField("root", fmt.Sprintf("%#x", origin)).Info("Origin checkpoint found in the database, ignoring checkpoint sync flags")
|
||||
return nil
|
||||
}
|
||||
if err != nil && !errors.Is(err, db.ErrNotFound) {
|
||||
|
||||
@@ -44,7 +44,7 @@ type FileInitializer struct {
|
||||
func (fi *FileInitializer) Initialize(ctx context.Context, d db.Database) error {
|
||||
origin, err := d.OriginCheckpointBlockRoot(ctx)
|
||||
if err == nil && origin != params.BeaconConfig().ZeroHash {
|
||||
log.Warnf("Origin checkpoint root %#x found in db, ignoring checkpoint sync flags", origin)
|
||||
log.WithField("root", fmt.Sprintf("%#x", origin)).Info("Origin checkpoint found in the database, ignoring checkpoint sync flags")
|
||||
return nil
|
||||
} else {
|
||||
if !errors.Is(err, db.ErrNotFound) {
|
||||
|
||||
6
changelog/manu-logs.md
Normal file
6
changelog/manu-logs.md
Normal file
@@ -0,0 +1,6 @@
|
||||
### Changed
|
||||
|
||||
- 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` from WARN to INFO, since it is the expected behaviour.
|
||||
@@ -2,7 +2,10 @@ load("@prysm//tools/go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["options.go"],
|
||||
srcs = [
|
||||
"log.go",
|
||||
"options.go",
|
||||
],
|
||||
importpath = "github.com/OffchainLabs/prysm/v7/cmd/beacon-chain/genesis",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
|
||||
5
cmd/beacon-chain/genesis/log.go
Normal file
5
cmd/beacon-chain/genesis/log.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package genesis
|
||||
|
||||
import "github.com/sirupsen/logrus"
|
||||
|
||||
var log = logrus.WithField("prefix", "genesis")
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"github.com/OffchainLabs/prysm/v7/cmd/beacon-chain/sync/checkpoint"
|
||||
"github.com/OffchainLabs/prysm/v7/genesis"
|
||||
"github.com/pkg/errors"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ go_library(
|
||||
"interop.go",
|
||||
"io_config.go",
|
||||
"loader.go",
|
||||
"log.go",
|
||||
"mainnet_config.go",
|
||||
"minimal_config.go",
|
||||
"network_config.go",
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
5
config/params/log.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package params
|
||||
|
||||
import "github.com/sirupsen/logrus"
|
||||
|
||||
var log = logrus.WithField("prefix", "params")
|
||||
@@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user