forked from TrueCloudLab/frostfs-node
[#493] logger: Do not set global fields in constructor
Remove setting of `app_name` and `app_version` fields in `NewLogger` constructor. Set these fields in Node and IR application in already constructed log and remove them from viper . Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
d17526f8ac
commit
2a970b0125
4 changed files with 11 additions and 17 deletions
|
@ -27,20 +27,10 @@ func NewLogger(v *viper.Viper) (*Logger, error) {
|
|||
c.Encoding = "console"
|
||||
c.EncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder
|
||||
|
||||
l, err := c.Build(
|
||||
return c.Build(
|
||||
// record a stack trace for all messages at or above fatal level
|
||||
zap.AddStacktrace(zap.NewAtomicLevelAt(zap.FatalLevel)),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
name := v.GetString("app.name")
|
||||
version := v.GetString("app.version")
|
||||
|
||||
return l.With(
|
||||
zap.String("app_name", name),
|
||||
zap.String("app_version", version)), nil
|
||||
}
|
||||
|
||||
func safeLevel(lvl string) zap.AtomicLevel {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue