Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

version: log charon version info on startup #1276

Merged
merged 3 commits into from
Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.LogCharonInfo(ctx, "Charon starting")

// Wire processes and their dependencies
life := new(lifecycle.Manager)
Expand Down
18 changes: 17 additions & 1 deletion app/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -40,3 +46,13 @@ func GitCommit() (hash string, timestamp string) {

return hash, timestamp
}

// LogCharonInfo logs charon version information along-with the provided message.
func LogCharonInfo(ctx context.Context, msg string) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i couldn't up with a better name, so suggestions welcome

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

version.LogInfo

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Charon" is superfluous, since everything in this codebase is charon...

gitHash, gitTimestamp := GitCommit()
log.Info(ctx, msg,
z.Str("version", Version),
z.Str("git_commit_hash", gitHash),
z.Str("git_commit_time", gitTimestamp),
)
}
3 changes: 3 additions & 0 deletions cmd/bootnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -94,6 +95,8 @@ func RunBootnode(ctx context.Context, config BootnodeConfig) error {
return err
}

version.LogCharonInfo(ctx, "Charon bootnode starting")

key, err := p2p.LoadPrivKey(config.DataDir)
if errors.Is(err, os.ErrNotExist) {
if !config.AutoP2PKey {
Expand Down
3 changes: 3 additions & 0 deletions cmd/createdkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -92,6 +93,8 @@ func runCreateDKG(ctx context.Context, conf createDKGConfig) (err error) {
}
}()

version.LogCharonInfo(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")
}
Expand Down
3 changes: 3 additions & 0 deletions dkg/dkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -68,6 +69,8 @@ func Run(ctx context.Context, conf Config) (err error) {
return err
}

version.LogCharonInfo(ctx, "Charon DKG starting")

def, err := loadDefinition(ctx, conf)
if err != nil {
return err
Expand Down