升级数据库日志, 增加sql类型
This commit is contained in:
		| @ -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() | ||||
| 	} | ||||
|  | ||||
		Reference in New Issue
	
	Block a user