Commit 587cdf55 authored by JiebinHu's avatar JiebinHu

feat:去掉logger

parent 1f06749b
......@@ -6,10 +6,8 @@ import (
_ "github.com/joho/godotenv/autoload"
"gorm.io/driver/mysql"
"gorm.io/gorm"
"gorm.io/gorm/logger"
"gorm.io/gorm/schema"
"hilo-socketCenter/common/config"
"hilo-socketCenter/common/mylogrus"
"log"
"net/url"
"time"
......@@ -23,18 +21,18 @@ func init() {
options := "?charset=utf8mb4&parseTime=True&loc=Local&time_zone=" + url.QueryEscape("'+8:00'")
dsn := "" + mysqlConfigData.MYSQL_USERNAME + ":" + mysqlConfigData.MYSQL_PASSWORD + "@(" + mysqlConfigData.MYSQL_HOST + ")/" + mysqlConfigData.MYSQL_DB + options
sqlLogger := logger.Default.LogMode(logger.Error) // 这个服务不需要
if file := mylogrus.GetSqlLog(); file != nil {
//sqlLogger = logger.New(log.New(file, "\r\n", log.Ldate|log.Lmicroseconds), logger.Config{
sqlLogger = MyNew(log.New(file, "", log.Ldate|log.Lmicroseconds), logger.Config{
SlowThreshold: 200 * time.Millisecond,
LogLevel: logger.Info,
Colorful: false,
})
}
//sqlLogger := logger.Default.LogMode(logger.Error) // 这个服务不需要
//if file := mylogrus.GetSqlLog(); file != nil {
// //sqlLogger = logger.New(log.New(file, "\r\n", log.Ldate|log.Lmicroseconds), logger.Config{
// sqlLogger = MyNew(log.New(file, "", log.Ldate|log.Lmicroseconds), logger.Config{
// SlowThreshold: 200 * time.Millisecond,
// LogLevel: logger.Info,
// Colorful: false,
// })
//}
Db, err = gorm.Open(mysql.Open(dsn), &gorm.Config{
Logger: sqlLogger,
//Logger: sqlLogger,
NamingStrategy: schema.NamingStrategy{
SingularTable: true,
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment