完善日志等级
Some checks failed
build / build (api, amd64, linux) (push) Failing after -50s
build / build (api, arm64, linux) (push) Failing after -51s
build / build (api.exe, amd64, windows) (push) Failing after -51s

This commit is contained in:
CN-JS-HuiBai
2026-04-18 02:23:36 +08:00
parent f4872bd12e
commit 8cf8bd6724
3 changed files with 21 additions and 4 deletions

View File

@@ -3,6 +3,7 @@ package database
import (
"fmt"
"log"
"strings"
"xboard-go/internal/config"
"xboard-go/internal/model"
@@ -46,9 +47,11 @@ func InitDB() {
}
func gormLogLevel(level string) logger.LogLevel {
switch config.NormalizeLogLevel(level) {
case "debug", "info":
switch strings.ToLower(strings.TrimSpace(level)) {
case "debug":
return logger.Info
case "info":
return logger.Warn // Site request logs are handled by Gin, suppress GORM SQL logs in info
case "warn":
return logger.Warn
case "error":
@@ -56,6 +59,6 @@ func gormLogLevel(level string) logger.LogLevel {
case "silent":
return logger.Silent
default:
return logger.Info
return logger.Warn
}
}