diff --git a/go.mod b/go.mod index 8bdf2f6..c920392 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/gin-gonic/gin v1.9.1 github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible github.com/pkg/errors v0.9.1 - go.uber.org/zap v1.25.0 + go.uber.org/zap v1.26.0 gorm.io/gorm v1.25.3 ) diff --git a/go.sum b/go.sum index ebeeac4..c85ba23 100644 --- a/go.sum +++ b/go.sum @@ -88,6 +88,8 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.25.0 h1:4Hvk6GtkucQ790dqmj7l1eEnRdKm3k3ZUrUMS2d5+5c= go.uber.org/zap v1.25.0/go.mod h1:JIAUzQIH94IC4fOJQm7gMmBJP5k7wQfdcnYdPoEXJYk= +go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= +go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/arch v0.4.0 h1:A8WCeEWhLwPBKNbFi5Wv5UTCBx5zzubnXDlMOFAzFMc= golang.org/x/arch v0.4.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= diff --git a/wrapper/gorm_v2.go b/wrapper/gorm_v2.go index 330935f..944fc73 100644 --- a/wrapper/gorm_v2.go +++ b/wrapper/gorm_v2.go @@ -141,6 +141,7 @@ func (g *Gorm) Trace(ctx context.Context, begin time.Time, fc func() (string, in dataList := []zap.Field{ zap.String("db_flag", g.flag), + zap.String("db_node", g.node), zap.Int64("begin_time", start), zap.Int64("finish_time", end), zap.String("used_time", fmt.Sprintf("%fms", float64(end-start)/1e6)), @@ -176,10 +177,6 @@ func (g *Gorm) write(dataList []zap.Field, level string) { } } - // 补齐 flag、node - sql := g.dbClient.Dialector.Explain(g.dbClient.Statement.SQL.String(), g.dbClient.Statement.Vars...) - affectRows := g.dbClient.RowsAffected - dataList = append(dataList, zap.String("db_node", g.node), zap.String("execute_sql", sql), zap.Int64("affect_rows", affectRows)) message := "SQL执行记录" switch strings.ToLower(level) { case "info":