diff --git a/app/app.go b/app/app.go index ad546af8e..cc139cd5b 100644 --- a/app/app.go +++ b/app/app.go @@ -131,12 +131,7 @@ func Run(ctx context.Context, conf Config) (err error) { return err } - gitHash, gitTimestamp := version.GitCommit() - log.Info(ctx, "Charon starting", - z.Str("version", version.Version), - z.Str("git_commit_hash", gitHash), - z.Str("git_commit_time", gitTimestamp), - ) + version.LogInfo(ctx, "Charon starting") // Wire processes and their dependencies life := new(lifecycle.Manager) diff --git a/app/version/version.go b/app/version/version.go index 064a6d82b..85f0447a2 100644 --- a/app/version/version.go +++ b/app/version/version.go @@ -15,7 +15,13 @@ package version -import "runtime/debug" +import ( + "context" + "runtime/debug" + + "github.com/obolnetwork/charon/app/log" + "github.com/obolnetwork/charon/app/z" +) // Version is the release version of the codebase. // Usually overridden by tag names when building binaries. @@ -40,3 +46,13 @@ func GitCommit() (hash string, timestamp string) { return hash, timestamp } + +// LogInfo logs charon version information along-with the provided message. +func LogInfo(ctx context.Context, msg string) { + gitHash, gitTimestamp := GitCommit() + log.Info(ctx, msg, + z.Str("version", Version), + z.Str("git_commit_hash", gitHash), + z.Str("git_commit_time", gitTimestamp), + ) +} diff --git a/cmd/bootnode.go b/cmd/bootnode.go index 93de39a78..fc5168796 100644 --- a/cmd/bootnode.go +++ b/cmd/bootnode.go @@ -32,6 +32,7 @@ import ( "github.com/obolnetwork/charon/app/errors" "github.com/obolnetwork/charon/app/log" + "github.com/obolnetwork/charon/app/version" "github.com/obolnetwork/charon/app/z" "github.com/obolnetwork/charon/p2p" ) @@ -94,6 +95,8 @@ func RunBootnode(ctx context.Context, config BootnodeConfig) error { return err } + version.LogInfo(ctx, "Charon bootnode starting") + key, err := p2p.LoadPrivKey(config.DataDir) if errors.Is(err, os.ErrNotExist) { if !config.AutoP2PKey { diff --git a/cmd/createdkg.go b/cmd/createdkg.go index 8ae51febc..259a9e649 100644 --- a/cmd/createdkg.go +++ b/cmd/createdkg.go @@ -27,6 +27,7 @@ import ( "github.com/obolnetwork/charon/app/errors" "github.com/obolnetwork/charon/app/log" + "github.com/obolnetwork/charon/app/version" "github.com/obolnetwork/charon/app/z" "github.com/obolnetwork/charon/cluster" "github.com/obolnetwork/charon/eth2util" @@ -92,6 +93,8 @@ func runCreateDKG(ctx context.Context, conf createDKGConfig) (err error) { } }() + version.LogInfo(ctx, "Charon create DKG starting") + if _, err := os.Stat(path.Join(conf.OutputDir, "cluster-definition.json")); err == nil { return errors.New("existing cluster-definition.json found. Try again after deleting it") } diff --git a/dkg/dkg.go b/dkg/dkg.go index 17f0c4a7c..b90ed26f9 100644 --- a/dkg/dkg.go +++ b/dkg/dkg.go @@ -30,6 +30,7 @@ import ( "github.com/obolnetwork/charon/app/errors" "github.com/obolnetwork/charon/app/log" + "github.com/obolnetwork/charon/app/version" "github.com/obolnetwork/charon/app/z" "github.com/obolnetwork/charon/cluster" "github.com/obolnetwork/charon/core" @@ -68,6 +69,8 @@ func Run(ctx context.Context, conf Config) (err error) { return err } + version.LogInfo(ctx, "Charon DKG starting") + def, err := loadDefinition(ctx, conf) if err != nil { return err