From 1fa49bca9c79f2e8e099ad2b34c3b5c5735909eb Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Tue, 11 May 2021 12:25:14 +0300 Subject: [PATCH] [#493] logger: Write app version once on start Writing application version in each log message seems pretty redundant. Remove global `app_version` field from Node/IR loggers. Write version, build time and debug flag once on start. Signed-off-by: Leonard Lyubich --- cmd/neofs-ir/main.go | 10 +++++----- cmd/neofs-node/config.go | 4 ---- cmd/neofs-node/main.go | 7 ++++++- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/cmd/neofs-ir/main.go b/cmd/neofs-ir/main.go index 4e3eaafa0..47e15c620 100644 --- a/cmd/neofs-ir/main.go +++ b/cmd/neofs-ir/main.go @@ -54,10 +54,6 @@ func main() { log, err := logger.NewLogger(logPrm) exitErr(err) - log = log.With( - zap.String("app_version", misc.Version), - ) - ctx := grace.NewGracefulContext(log) intErr := make(chan error) // internal inner ring errors @@ -97,7 +93,11 @@ func main() { exitErr(err) } - log.Info("application started") + log.Info("application started", + zap.String("build time", misc.Build), + zap.String("version", misc.Version), + zap.String("debug", misc.Debug), + ) select { case <-ctx.Done(): diff --git a/cmd/neofs-node/config.go b/cmd/neofs-node/config.go index 754715730..31974ed1c 100644 --- a/cmd/neofs-node/config.go +++ b/cmd/neofs-node/config.go @@ -362,10 +362,6 @@ func initCfg(path string) *cfg { log, err := logger.NewLogger(logPrm) fatalOnErr(err) - log = log.With( - zap.String("app_version", misc.Version), - ) - netAddr, err := network.AddressFromString(viperCfg.GetString(cfgBootstrapAddress)) fatalOnErr(err) diff --git a/cmd/neofs-node/main.go b/cmd/neofs-node/main.go index d4969fa2c..ba2dcbaed 100644 --- a/cmd/neofs-node/main.go +++ b/cmd/neofs-node/main.go @@ -5,6 +5,7 @@ import ( "flag" "log" + "github.com/nspcc-dev/neofs-node/misc" "github.com/nspcc-dev/neofs-node/pkg/services/control" "github.com/nspcc-dev/neofs-node/pkg/util/grace" "go.uber.org/zap" @@ -68,7 +69,11 @@ func bootUp(c *cfg) { } func wait(c *cfg) { - c.log.Info("application started") + c.log.Info("application started", + zap.String("build time", misc.Build), + zap.String("version", misc.Version), + zap.String("debug", misc.Debug), + ) select { case <-c.ctx.Done(): // graceful shutdown