修复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()
|
sql, affectRows = fc()
|
||||||
}
|
}
|
||||||
|
|
||||||
g.write(ctx, "SQL执行记录", consts.LogLevelInfo, map[string]any{
|
logData := map[string]any{
|
||||||
"db_flag": g.flag,
|
"db_flag": g.flag,
|
||||||
"db_node": g.node,
|
"db_node": g.node,
|
||||||
"begin_time": start,
|
"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,
|
"used_time": (end - start) / 1e6,
|
||||||
"sql": sql,
|
"sql": sql,
|
||||||
"affect_rows": affectRows,
|
"affect_rows": affectRows,
|
||||||
"err": err.Error(),
|
"err": "",
|
||||||
})
|
}
|
||||||
|
if nil != err {
|
||||||
|
logData["err"] = err.Error()
|
||||||
|
}
|
||||||
|
g.write(ctx, "SQL执行记录", consts.LogLevelInfo, logData)
|
||||||
}
|
}
|
||||||
|
|
||||||
// write ...
|
// write ...
|
||||||
|
Loading…
Reference in New Issue
Block a user