升级数据库日志, 增加sql类型
This commit is contained in:
parent
d6b517ea7a
commit
8ae4053b24
@ -9,6 +9,7 @@ package wrapper
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -175,6 +176,13 @@ func (g *Gorm) write(ctx context.Context, message string, level string, data map
|
|||||||
if nil == data {
|
if nil == data {
|
||||||
data = make(map[string]any)
|
data = make(map[string]any)
|
||||||
}
|
}
|
||||||
|
if nil != data["sql"] {
|
||||||
|
sqlStr := strings.TrimSpace(fmt.Sprintf("%v", data["sql"]))
|
||||||
|
sqlArr := strings.Split(sqlStr, " ")
|
||||||
|
if len(sqlArr) > 0 {
|
||||||
|
message = fmt.Sprintf("【%v】" + message)
|
||||||
|
}
|
||||||
|
}
|
||||||
if nil == g.outCtx {
|
if nil == g.outCtx {
|
||||||
g.outCtx = context.Background()
|
g.outCtx = context.Background()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user