diff --git a/cmd/main.go b/cmd/main.go index 03199c7..cae629e 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -78,8 +78,7 @@ func start(cliCtx *cli.Context) error { setupLog(c.Log) - agglayer.PrintVersion(os.Stdout) - log.Info("Starting application...") + log.Infof("Starting application... %s", agglayer.GetVersionInfo()) // Prepare DB pg, err := dbConf.NewSQLDB(c.DB) diff --git a/version.go b/version.go index 40464fd..6681c66 100644 --- a/version.go +++ b/version.go @@ -16,10 +16,16 @@ var ( // PrintVersion prints version info into the provided io.Writer. func PrintVersion(w io.Writer) { - fmt.Fprintf(w, "Version: %s\n", Version) - fmt.Fprintf(w, "Git revision: %s\n", GitRev) - fmt.Fprintf(w, "Git branch: %s\n", GitBranch) - fmt.Fprintf(w, "Go version: %s\n", runtime.Version()) - fmt.Fprintf(w, "Built: %s\n", BuildDate) - fmt.Fprintf(w, "OS/Arch: %s/%s\n", runtime.GOOS, runtime.GOARCH) + fmt.Fprint(w, GetVersionInfo()) +} + +// GetVersionInfo returns version information as a formatted string. +func GetVersionInfo() string { + versionInfo := fmt.Sprintf("Version: %s\n", Version) + versionInfo += fmt.Sprintf("Git revision: %s\n", GitRev) + versionInfo += fmt.Sprintf("Git branch: %s\n", GitBranch) + versionInfo += fmt.Sprintf("Go version: %s\n", runtime.Version()) + versionInfo += fmt.Sprintf("Built: %s\n", BuildDate) + versionInfo += fmt.Sprintf("OS/Arch: %s/%s\n", runtime.GOOS, runtime.GOARCH) + return versionInfo }