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

Fix versionFlag to output to stdout #710

Merged
merged 3 commits into from
Jan 31, 2025
Merged

Conversation

coincashew
Copy link
Contributor

@coincashew coincashew commented Dec 20, 2024

📝 Summary

Rollsback a change which affected the versionFlag output
mev-boost --version
outputs to stdout once again.

Version output is currently outputting to stderr.

⛱ Motivation and Context

Fixes coincashew/EthPillar#47

Before


After

mev-boost v1.8.1-6-gc574ad2-dev

cli/main.go Outdated
@@ -55,7 +55,7 @@ func Main() {
func start(_ context.Context, cmd *cli.Command) error {
// Only print the version if the flag is set
if cmd.IsSet(versionFlag.Name) {
log.Infof("mev-boost %s\n", config.Version)
fmt.Printf("mev-boost %s\n", config.Version) //nolint
Copy link
Collaborator

Choose a reason for hiding this comment

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

probably better to do the setupLogging step first, which sets it to stdout, and keep using log.Infof.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think using fmt.Printf here is the right thing actually. Otherwise, the output is difficult to parse:

$ ./mev-boost --version
INFO[2025-01-31T08:45:58.966-06:00] starting mev-boost                            version=3c51355-dev
INFO[2025-01-31T08:45:58.966-06:00] mev-boost 3c51355-dev                         version=3c51355-dev

And this would break EthPillar's regex here:

MB=$(if [[ -f /etc/systemd/system/mevboost.service ]]; then printf "Mev-boost: $(mev-boost --version | sed 's/.*\s\([0-9]*\.[0-9]*\).*/\1/')"; else printf "Mev-boost: Not Installed"; fi)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I've updated the PR to do this instead:

fmt.Fprintf(cmd.Writer, "mev-boost %s\n", config.Version)

I believe this is most appropriate for CLI apps. Doesn't require //nolint either.

@jtraglia
Copy link
Collaborator

Thanks @coincashew! I'm going to merge this now.

@jtraglia jtraglia merged commit c99f1d5 into flashbots:develop Jan 31, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mev-boost v1.7+ no longer outputs version to stdout
3 participants