Skip to content

Commit

Permalink
Update logger to add goid
Browse files Browse the repository at this point in the history
  • Loading branch information
huangyitai committed Nov 9, 2023
1 parent 6b7854a commit b1b7bcb
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions logger/zap.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package logger

import (
"fmt"
"strings"
"time"

"github.com/petermattis/goid"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"gopkg.in/natefinch/lumberjack.v2"
"strings"
"time"
)

var levelStringList = []string{"debug", "info", "warn", "error", "fatal"}
Expand Down Expand Up @@ -63,7 +66,7 @@ func InitArchiveZapLogger(config LogConfig) (zapLogger *zap.Logger) {
if len(trimPath) > 40 {
trimPath = trimPath[len(trimPath)-40:]
}
enc.AppendString("[] [" + trimPath + "]")
enc.AppendString("[" + fmt.Sprintf("goid-%d", goid.Get()) + "]" + "[" + trimPath + "]")
}
zCore := zapcore.NewCore(zapcore.NewConsoleEncoder(encoderConfig), zapcore.NewMultiWriteSyncer(zapcore.AddSync(&hook)), zapLevel)
zapLogger = zap.New(zCore, zap.AddCaller(), zap.Development())
Expand Down

0 comments on commit b1b7bcb

Please sign in to comment.