From ac9f68c80dcf658bd5ac9dcf6719413572819c02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AF=BB=E6=AC=A2?= Date: Thu, 7 Dec 2023 23:00:16 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E6=89=93=E5=8D=B0=20sql=20=E8=AF=AD?= =?UTF-8?q?=E5=8F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/mysql.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/client/mysql.go b/client/mysql.go index d40ae9f..eb774c1 100644 --- a/client/mysql.go +++ b/client/mysql.go @@ -4,6 +4,7 @@ import ( "go-wechat/config" "gorm.io/driver/mysql" "gorm.io/gorm" + "gorm.io/gorm/logger" "log" ) @@ -17,7 +18,13 @@ func InitMySQLClient() { DontSupportRenameIndex: true, // 重命名索引时采用删除并新建的方式 DontSupportRenameColumn: true, // 用 `change` 重命名列 } - conn, err := gorm.Open(mysql.New(mysqlConfig)) + + // gorm 配置 + gormConfig := gorm.Config{ + Logger: logger.Default.LogMode(logger.Info), + } + + conn, err := gorm.Open(mysql.New(mysqlConfig), &gormConfig) if err != nil { log.Panicf("初始化MySQL连接失败, 错误信息: %v", err) } else {