From 947293f34e20d09637b5e2e5e155bbea81212fcc Mon Sep 17 00:00:00 2001 From: zhengkunwang223 Date: Wed, 5 Apr 2023 20:17:52 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E6=97=A5=E5=BF=97=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/init/db/db.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/backend/init/db/db.go b/backend/init/db/db.go index 64b67b3f4..4f081c37f 100644 --- a/backend/init/db/db.go +++ b/backend/init/db/db.go @@ -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)