[#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 <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-05-11 12:25:14 +03:00 committed by Alex Vanin
parent bec4507997
commit 1fa49bca9c
3 changed files with 11 additions and 10 deletions

View file

@ -54,10 +54,6 @@ func main() {
log, err := logger.NewLogger(logPrm) log, err := logger.NewLogger(logPrm)
exitErr(err) exitErr(err)
log = log.With(
zap.String("app_version", misc.Version),
)
ctx := grace.NewGracefulContext(log) ctx := grace.NewGracefulContext(log)
intErr := make(chan error) // internal inner ring errors intErr := make(chan error) // internal inner ring errors
@ -97,7 +93,11 @@ func main() {
exitErr(err) 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 { select {
case <-ctx.Done(): case <-ctx.Done():

View file

@ -362,10 +362,6 @@ func initCfg(path string) *cfg {
log, err := logger.NewLogger(logPrm) log, err := logger.NewLogger(logPrm)
fatalOnErr(err) fatalOnErr(err)
log = log.With(
zap.String("app_version", misc.Version),
)
netAddr, err := network.AddressFromString(viperCfg.GetString(cfgBootstrapAddress)) netAddr, err := network.AddressFromString(viperCfg.GetString(cfgBootstrapAddress))
fatalOnErr(err) fatalOnErr(err)

View file

@ -5,6 +5,7 @@ import (
"flag" "flag"
"log" "log"
"github.com/nspcc-dev/neofs-node/misc"
"github.com/nspcc-dev/neofs-node/pkg/services/control" "github.com/nspcc-dev/neofs-node/pkg/services/control"
"github.com/nspcc-dev/neofs-node/pkg/util/grace" "github.com/nspcc-dev/neofs-node/pkg/util/grace"
"go.uber.org/zap" "go.uber.org/zap"
@ -68,7 +69,11 @@ func bootUp(c *cfg) {
} }
func wait(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 { select {
case <-c.ctx.Done(): // graceful shutdown case <-c.ctx.Done(): // graceful shutdown