feat: 升级日志

This commit is contained in:
2025-10-31 12:42:00 +08:00
parent 1f20a8fc9e
commit 58d0c8687b
3 changed files with 20 additions and 7 deletions

View File

@ -26,7 +26,7 @@ import (
)
// NewGormV2 获取日志实例
func NewGormV2(loggerLevel consts.LogLevel, consoleOutput bool, encoder zapcore.Encoder, splitConfig *loggerPkg.RotateLogConfig, traceIDField string, skip int) (logger.Interface, error) {
func NewGormV2(loggerLevel loggerPkg.LogLevel, consoleOutput bool, encoder zapcore.Encoder, splitConfig *loggerPkg.RotateLogConfig, traceIDField string, skip int) (logger.Interface, error) {
logConfList := []loggerPkg.SetLoggerOptionFunc{loggerPkg.WithEncoder(encoder), loggerPkg.WithCallerSkip(skip), loggerPkg.WithCaller()}
if consoleOutput {
logConfList = append(logConfList, loggerPkg.WithConsoleOutput())
@ -151,7 +151,7 @@ func (g *Gorm) write(ctx context.Context, message string, level consts.LogLevel,
g.outCtx = context.Background()
}
dataList := loggerPkg.ZapLogDataList(loggerPkg.NewLogData(g.outCtx, consts.LogTypeDatabase, "", data))
dataList := loggerPkg.NewLogData(g.outCtx, consts.LogTypeDatabase, "", data).ToFieldList()
switch level {
case consts.LogLevelDebug:
g.instance.Debug(message, dataList...)