feat: 增加数据库日志配置

pull/515/head
zhengkunwang223 2 years ago committed by zhengkunwang223
parent 04a76fd94d
commit 947293f34e

@ -2,6 +2,8 @@ package db
import (
"fmt"
"gorm.io/gorm/logger"
"log"
"os"
"time"
@ -24,8 +26,19 @@ func Init() {
}
}
newLogger := logger.New(
log.New(os.Stdout, "\r\n", log.LstdFlags),
logger.Config{
SlowThreshold: time.Second,
LogLevel: logger.Silent,
IgnoreRecordNotFoundError: true,
Colorful: false,
},
)
db, err := gorm.Open(sqlite.Open(fullPath), &gorm.Config{
DisableForeignKeyConstraintWhenMigrating: true,
Logger: newLogger,
})
if err != nil {
panic(err)

Loading…
Cancel
Save