Skip to content

Commit

Permalink
Merge pull request #17 from goriller/feat/new
Browse files Browse the repository at this point in the history
fix: add caller
  • Loading branch information
richenlin authored Apr 3, 2023
2 parents d24a076 + 9bbabac commit cbb1640
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions logger/zap.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func init() {
cores := make([]zapcore.Core, 0, 1)
encoderCfg := zap.NewProductionEncoderConfig()
encoderCfg.TimeKey = "time"
encoderCfg.CallerKey = ""
encoderCfg.CallerKey = "caller"
encoderCfg.EncodeTime = zapcore.RFC3339NanoTimeEncoder
if logFilePath != "" {
fw := zapcore.AddSync(&lumberjack.Logger{
Expand All @@ -51,7 +51,11 @@ func init() {
}

core := zapcore.NewTee(cores...)
std = zap.New(core)
opt := []zap.Option{
zap.AddCaller(),
zap.AddCallerSkip(1),
}
std = zap.New(core, opt...)
zap.ReplaceGlobals(std)

graceful.AddCloser(func(ctx context.Context) error {
Expand Down

0 comments on commit cbb1640

Please sign in to comment.