Skip to content

[IDEA] Colorful feature maybe is needed. please consider add Colorful feature. #176

@yyle88

Description

@yyle88

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

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions