This commit is contained in:
wangchuxiao
2023-03-14 11:09:55 +08:00
parent 8c931818fd
commit eeffefc9fc
2 changed files with 19 additions and 6 deletions
+8 -2
View File
@@ -6,6 +6,7 @@ import (
"context"
"fmt"
"gorm.io/driver/mysql"
"strings"
"time"
"gorm.io/gorm"
@@ -67,6 +68,11 @@ func NewGormDB() (*gorm.DB, error) {
type Writer struct{}
func (w Writer) Printf(format string, args ...interface{}) {
sql := fmt.Sprintf(format, args...)
log.ZDebug(context.Background(), "", "sql", sql)
s := fmt.Sprintf(format, args...)
l := strings.Split(s, "\n")
if len(l) == 2 {
log.ZDebug(context.Background(), "sql exec detail", "gorm", l[0], "sql", l[1])
} else {
log.ZDebug(context.Background(), "sql exec detail", "sql", s)
}
}