This commit is contained in:
wangchuxiao 2023-04-17 21:39:31 +08:00
parent f18b03987e
commit c04b85aa29

View File

@ -3,6 +3,7 @@ package log
import (
"context"
"errors"
"fmt"
"os"
"path/filepath"
"time"
@ -111,7 +112,9 @@ func (l *ZapLogger) cores(isStdout bool, isJson bool, logLocation string, rotate
c.EncodeLevel = l.CapitalColorLevelEncoder
customCallerEncoder := func(caller zapcore.EntryCaller, enc zapcore.PrimitiveArrayEncoder) {
s := "[" + caller.TrimmedPath() + "]"
pid := fmt.Sprintf("["+"PID:"+"%d"+"]", os.Getpid())
enc.AppendString(_levelToColor[l.level].Add(s))
enc.AppendString(_levelToColor[l.level].Add(pid))
}
c.EncodeCaller = customCallerEncoder
fileEncoder = zapcore.NewConsoleEncoder(c)