Commit 587cdf55 authored by JiebinHu's avatar JiebinHu

feat:去掉logger

parent 1f06749b
...@@ -6,10 +6,8 @@ import ( ...@@ -6,10 +6,8 @@ import (
_ "github.com/joho/godotenv/autoload" _ "github.com/joho/godotenv/autoload"
"gorm.io/driver/mysql" "gorm.io/driver/mysql"
"gorm.io/gorm" "gorm.io/gorm"
"gorm.io/gorm/logger"
"gorm.io/gorm/schema" "gorm.io/gorm/schema"
"hilo-socketCenter/common/config" "hilo-socketCenter/common/config"
"hilo-socketCenter/common/mylogrus"
"log" "log"
"net/url" "net/url"
"time" "time"
...@@ -23,18 +21,18 @@ func init() { ...@@ -23,18 +21,18 @@ func init() {
options := "?charset=utf8mb4&parseTime=True&loc=Local&time_zone=" + url.QueryEscape("'+8:00'") 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 dsn := "" + mysqlConfigData.MYSQL_USERNAME + ":" + mysqlConfigData.MYSQL_PASSWORD + "@(" + mysqlConfigData.MYSQL_HOST + ")/" + mysqlConfigData.MYSQL_DB + options
sqlLogger := logger.Default.LogMode(logger.Error) // 这个服务不需要 //sqlLogger := logger.Default.LogMode(logger.Error) // 这个服务不需要
if file := mylogrus.GetSqlLog(); file != nil { //if file := mylogrus.GetSqlLog(); file != nil {
//sqlLogger = logger.New(log.New(file, "\r\n", log.Ldate|log.Lmicroseconds), logger.Config{ // //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{ // sqlLogger = MyNew(log.New(file, "", log.Ldate|log.Lmicroseconds), logger.Config{
SlowThreshold: 200 * time.Millisecond, // SlowThreshold: 200 * time.Millisecond,
LogLevel: logger.Info, // LogLevel: logger.Info,
Colorful: false, // Colorful: false,
}) // })
} //}
Db, err = gorm.Open(mysql.Open(dsn), &gorm.Config{ Db, err = gorm.Open(mysql.Open(dsn), &gorm.Config{
Logger: sqlLogger, //Logger: sqlLogger,
NamingStrategy: schema.NamingStrategy{ NamingStrategy: schema.NamingStrategy{
SingularTable: true, 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