Skip to content

Commit

Permalink
Log startup info as JSON in production (0xPolygonHermez#1799)
Browse files Browse the repository at this point in the history
This commit changes the format of the startup info to be JSON when the
log `Environment` configuration is set to `production`.
  • Loading branch information
kind84 authored Mar 15, 2023
1 parent f01dc87 commit 3e07e4d
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"net/http/pprof"
"os"
"os/signal"
"runtime"
"time"

"github.com/0xPolygonHermez/zkevm-node"
Expand Down Expand Up @@ -42,13 +43,19 @@ const (
)

func start(cliCtx *cli.Context) error {
zkevm.PrintVersion(os.Stdout)

c, err := config.Load(cliCtx)
if err != nil {
return err
}
setupLog(c.Log)

if c.Log.Environment == log.EnvironmentDevelopment {
zkevm.PrintVersion(os.Stdout)
log.Info("Starting application")
} else if c.Log.Environment == log.EnvironmentProduction {
logVersion()
}

if c.Metrics.Enabled {
metrics.Init()
}
Expand Down Expand Up @@ -368,3 +375,14 @@ func startMetricsHttpServer(c metrics.Config) {
return
}
}

func logVersion() {
log.Infow("Starting application",
// node version is already logged by default
"gitRevision", zkevm.GitRev,
"gitBranch", zkevm.GitBranch,
"goVersion", runtime.Version(),
"built", zkevm.BuildDate,
"os/arch", fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH),
)
}

0 comments on commit 3e07e4d

Please sign in to comment.