完善日志等级
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
}
}

View File

@@ -582,6 +582,20 @@ func serializeAdminServer(server model.Server, groups map[int]model.ServerGroup,
isOnline = 2
}
// Inherit status from parent if current node is offline
if isOnline == 0 && server.ParentID != nil {
if parentServer, ok := servers[*server.ParentID]; ok {
pLastCheckAt, _ := database.CacheGetJSON[int64](nodeLastCheckKey(&parentServer))
pLastPushAt, _ := database.CacheGetJSON[int64](nodeLastPushKey(&parentServer))
if pLastCheckAt > 0 && now-pLastCheckAt <= 300 {
isOnline = 1
}
if pLastPushAt > 0 && now-pLastPushAt <= 300 {
isOnline = 2
}
}
}
availableStatus := 0
if isOnline == 1 {
availableStatus = 1