Skip to content

Commit 8c6a8e4

Browse files
committed
move custom common fields up
1 parent 7f904dd commit 8c6a8e4

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

logutil.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ func newLogger(lumberjackLogger *lumberjack.Logger, fp *os.File, lvl zapcore.Lev
7474
EncodeCaller: zapcore.ShortCallerEncoder,
7575
}
7676

77+
customCommonFields := zap.Fields(
78+
zap.Int("_pid", os.Getpid()),
79+
zap.String("_version", appVersion),
80+
)
81+
7782
coreSlice := make([]zapcore.Core, 0, 2)
7883

7984
if lumberjackLogger != nil {
@@ -104,11 +109,7 @@ func newLogger(lumberjackLogger *lumberjack.Logger, fp *os.File, lvl zapcore.Lev
104109
zap.AddCaller(),
105110
// Using errors package to get better stack traces
106111
// zap.AddStacktrace(stackTraceLvl),
107-
// TODO: replace with version (goreleaser embeds it)
108-
zap.Fields(
109-
zap.Int("pid", os.Getpid()),
110-
zap.String("version", appVersion),
111-
),
112+
customCommonFields,
112113
)
113114

114115
return logger

0 commit comments

Comments
 (0)