From ad25c69c7963f6270986063f631d3f97441013d5 Mon Sep 17 00:00:00 2001 From: qowevisa Date: Fri, 8 Nov 2024 17:05:23 +0200 Subject: [PATCH] Redirect db log into db.log file --- db/db.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/db/db.go b/db/db.go index dfd3d08..7a91e88 100644 --- a/db/db.go +++ b/db/db.go @@ -25,8 +25,12 @@ func Connect() *gorm.DB { if udb != nil { return udb } + logFile, err := os.OpenFile("db.log", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) + if err != nil { + panic(err) + } newLogger := logger.New( - log.New(os.Stdout, "\r\n", log.LstdFlags), + log.New(logFile, "\r\n", log.LstdFlags), logger.Config{ SlowThreshold: time.Second, LogLevel: logger.Error,