logger/gorm_test.go
2022-03-17 10:33:47 +08:00

23 lines
507 B
Go

package logger
import (
"gorm.io/driver/mysql"
"gorm.io/gorm"
"testing"
)
func TestGormLogger(t *testing.T) {
dsn := "saas:saas123@tcp(10.11.0.10:3307)/saas_tenant?charset=utf8mb4&parseTime=True&loc=Local"
engine, err := gorm.Open(mysql.Open(dsn), &gorm.Config{Logger: DefaultGormLogger()})
if err != nil {
Say.Panicf("mysql connect error: %s", err.Error())
}
var count int64
if err := engine.Table("t_tenant1").Count(&count).Error; err != nil {
t.Log(err)
}
t.Logf("count: %d", count)
}