forked from TrueCloudLab/frostfs-s3-gw
[#380] cmd/s3-gw: Write app name and version once on startup
It's redundant to write app name and version in each log message, a single entry at the start is enough. Make `App.Wait` to write app name as `neofs-s3-gw` in `application started` message. Do not add `app_name` and `app_version` fields to the logger returned by `newLogger`. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
01c721ee53
commit
83fb697f80
2 changed files with 9 additions and 8 deletions
|
@ -189,8 +189,15 @@ func newApp(ctx context.Context, l *zap.Logger, v *viper.Viper) *App {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait waits for application to finish.
|
// Wait waits for application to finish.
|
||||||
|
//
|
||||||
|
// Pre-logs a message about the launch of the application mentioning its
|
||||||
|
// version (version.Version) and name (neofs-s3-gw). At the end writes to the
|
||||||
|
// log about the stop.
|
||||||
func (a *App) Wait() {
|
func (a *App) Wait() {
|
||||||
a.log.Info("application started", zap.String("version", version.Version))
|
a.log.Info("application started",
|
||||||
|
zap.String("name", "neofs-s3-gw"),
|
||||||
|
zap.String("version", version.Version),
|
||||||
|
)
|
||||||
|
|
||||||
<-a.webDone // wait for web-server to be stopped
|
<-a.webDone // wait for web-server to be stopped
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@ import (
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-s3-gw/internal/version"
|
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"go.uber.org/zap/zapcore"
|
"go.uber.org/zap/zapcore"
|
||||||
|
@ -19,8 +18,6 @@ import (
|
||||||
// * parameterized level (debug by default)
|
// * parameterized level (debug by default)
|
||||||
// * console encoding
|
// * console encoding
|
||||||
// * ISO8601 time encoding
|
// * ISO8601 time encoding
|
||||||
// * app_name field set to neofs-s3-gw
|
|
||||||
// * app_version field set to version.Version
|
|
||||||
//
|
//
|
||||||
// Logger records a stack trace for all messages at or above fatal level.
|
// Logger records a stack trace for all messages at or above fatal level.
|
||||||
//
|
//
|
||||||
|
@ -55,10 +52,7 @@ func newLogger(v *viper.Viper) *zap.Logger {
|
||||||
panic(fmt.Sprintf("build zap logger instance: %v", err))
|
panic(fmt.Sprintf("build zap logger instance: %v", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
return l.With(
|
return l
|
||||||
zap.String("app_name", "neofs-s3-gw"),
|
|
||||||
zap.String("app_version", version.Version),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
Loading…
Reference in a new issue