修复mysql日志问题
This commit is contained in:
parent
f62e82ecd0
commit
f0cfac27b6
@ -32,6 +32,7 @@ func NewGormV2(loggerLevel zapcore.Level, consoleOutput bool, encoder zapcore.En
|
||||
if consoleOutput {
|
||||
logConfList = append(logConfList, logger2.WithConsoleOutput())
|
||||
}
|
||||
|
||||
logInstance, err := logger2.NewLogger(loggerLevel, splitConfig, logConfList...)
|
||||
if nil != err {
|
||||
return nil, err
|
||||
@ -39,6 +40,7 @@ func NewGormV2(loggerLevel zapcore.Level, consoleOutput bool, encoder zapcore.En
|
||||
if len(traceIDField) == 0 {
|
||||
traceIDField = "trace_id"
|
||||
}
|
||||
|
||||
return &Gorm{
|
||||
instance: logInstance,
|
||||
traceIDField: traceIDField,
|
||||
|
@ -10,6 +10,8 @@ package mysql
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.zhangdeman.cn/zhangdeman/gopkg/logger"
|
||||
|
||||
"git.zhangdeman.cn/zhangdeman/gopkg/logger/wrapper"
|
||||
|
||||
"gorm.io/driver/mysql"
|
||||
@ -35,11 +37,19 @@ func GetDatabaseClient(conf *DBConfig, logConf *LogConfig) (*gorm.DB, error) {
|
||||
logConf.TraceFieldName = defaultTraceFieldName
|
||||
}
|
||||
|
||||
splitConfigFuncList := []logger.SetRotateLogConfigFunc{
|
||||
logger.WithTimeIntervalType(logConf.SplitConfig.TimeIntervalType),
|
||||
logger.WithDivisionChar(logConf.SplitConfig.DivisionChar),
|
||||
logger.WithMaxAge(logConf.SplitConfig.MaxAge),
|
||||
}
|
||||
|
||||
splitConfig, _ := logger.NewRotateLogConfig(logConf.SplitConfig.LogPath, logConf.SplitConfig.LogFileName, splitConfigFuncList...)
|
||||
|
||||
if instance.Logger, err = wrapper.NewGormV2(
|
||||
logConf.Level,
|
||||
logConf.ConsoleOutput,
|
||||
logConf.Encoder,
|
||||
logConf.SplitConfig,
|
||||
splitConfig,
|
||||
logConf.TraceFieldName,
|
||||
logConf.Skip); nil != err {
|
||||
return nil, CreateDBLogError(err)
|
||||
|
Loading…
Reference in New Issue
Block a user