Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Commit 3e07e4d

Browse files
authored
Log startup info as JSON in production (#1799)
This commit changes the format of the startup info to be JSON when the log `Environment` configuration is set to `production`.
1 parent f01dc87 commit 3e07e4d

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

cmd/run.go

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"net/http/pprof"
99
"os"
1010
"os/signal"
11+
"runtime"
1112
"time"
1213

1314
"github.com/0xPolygonHermez/zkevm-node"
@@ -42,13 +43,19 @@ const (
4243
)
4344

4445
func start(cliCtx *cli.Context) error {
45-
zkevm.PrintVersion(os.Stdout)
46-
4746
c, err := config.Load(cliCtx)
4847
if err != nil {
4948
return err
5049
}
5150
setupLog(c.Log)
51+
52+
if c.Log.Environment == log.EnvironmentDevelopment {
53+
zkevm.PrintVersion(os.Stdout)
54+
log.Info("Starting application")
55+
} else if c.Log.Environment == log.EnvironmentProduction {
56+
logVersion()
57+
}
58+
5259
if c.Metrics.Enabled {
5360
metrics.Init()
5461
}
@@ -368,3 +375,14 @@ func startMetricsHttpServer(c metrics.Config) {
368375
return
369376
}
370377
}
378+
379+
func logVersion() {
380+
log.Infow("Starting application",
381+
// node version is already logged by default
382+
"gitRevision", zkevm.GitRev,
383+
"gitBranch", zkevm.GitBranch,
384+
"goVersion", runtime.Version(),
385+
"built", zkevm.BuildDate,
386+
"os/arch", fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH),
387+
)
388+
}

0 commit comments

Comments
 (0)