修复panic
This commit is contained in:
parent
0bc05b3816
commit
76e459ffcc
@ -143,7 +143,7 @@ func (g *Gorm) Trace(ctx context.Context, begin time.Time, fc func() (string, in
|
||||
sql, affectRows = fc()
|
||||
}
|
||||
|
||||
g.write(ctx, "SQL执行记录", consts.LogLevelInfo, map[string]any{
|
||||
logData := map[string]any{
|
||||
"db_flag": g.flag,
|
||||
"db_node": g.node,
|
||||
"begin_time": start,
|
||||
@ -151,8 +151,12 @@ func (g *Gorm) Trace(ctx context.Context, begin time.Time, fc func() (string, in
|
||||
"used_time": (end - start) / 1e6,
|
||||
"sql": sql,
|
||||
"affect_rows": affectRows,
|
||||
"err": err.Error(),
|
||||
})
|
||||
"err": "",
|
||||
}
|
||||
if nil != err {
|
||||
logData["err"] = err.Error()
|
||||
}
|
||||
g.write(ctx, "SQL执行记录", consts.LogLevelInfo, logData)
|
||||
}
|
||||
|
||||
// write ...
|
||||
|
Loading…
Reference in New Issue
Block a user