generated from moul/golang-repo-template
-
-
Notifications
You must be signed in to change notification settings - Fork 32
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
import (
"time"
"gorm.io/gorm/logger"
"gorm.io/gorm"
"gorm.io/driver/mysql"
)
func main() {
newLogger := logger.New(
logger.Default.LogMode(logger.Info), // 设置日志级别
logger.Config{
SlowThreshold: 200 * time.Millisecond, // 慢查询时间
LogLevel: logger.Info, // 日志级别
IgnoreRecordNotFoundError: true, // 忽略 ErrRecordNotFound 错误
Colorful: true, // 终端是否输出彩色
},
)
db, err := gorm.Open(mysql.Open("root:12345@tcp(127.0.0.1:3306)/testdb?charset=utf8mb4&parseTime=True"), &gorm.Config{
Logger: newLogger,
})
if err != nil {
panic("failed to connect database")
}
// 测试查询
var result int
db.Raw("SELECT 1").Scan(&result)
}
Describe the solution you'd like
A clear and concise description of what you want to happen.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
So I think it is very good to add Colorful feature.
Colorful: true, // 终端是否输出彩色
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request