newLogger := logger.New(log.New(os.Stdout, "\r\n", log.LstdFlags), logger.Config{
SlowThreshold: time.Second, // 满阈值
Colorful: true, // 日志颜色开启
ParameterizedQueries: false, // sql参数可见,true就是?
LogLevel: logger.Info, //日志级别
})
// 连接mysql并配置日志信息
DB, _ = gorm.Open(mysql.Open(viper.GetString("gin.datasource.url")), &gorm.Config{
Logger: newLogger,
})
标签:gorm,mysql,go,New,日志,logger
From: https://www.cnblogs.com/MnysLjj/p/17799985.html