升级数据库日志, 增加sql类型
This commit is contained in:
parent
d6b517ea7a
commit
8ae4053b24
@ -9,6 +9,7 @@ package wrapper
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -175,6 +176,13 @@ func (g *Gorm) write(ctx context.Context, message string, level string, data map
|
||||
if nil == data {
|
||||
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 {
|
||||
g.outCtx = context.Background()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user