From e96b4b067a4fc2b1f7fa08da5de77228ce4c5dab Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Sat, 23 May 2026 15:59:43 +0200 Subject: [PATCH] fix(db): silence GORM record-not-found spam in debug mode getSetting handles ErrRecordNotFound via database.IsNotFound and falls back to defaults, but GORM's Default logger still logs each miss as an error. With periodic jobs reading unset keys (xrayTemplateConfig, externalTrafficInformEnable) the panel log flooded thousands of times. Switch to a logger.New with IgnoreRecordNotFoundError=true so legitimate slow-query and SQL traces still surface in debug mode. --- database/db.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/database/db.go b/database/db.go index c92e315f..fba55a3c 100644 --- a/database/db.go +++ b/database/db.go @@ -346,7 +346,15 @@ func isTableEmpty(tableName string) (bool, error) { func InitDB(dbPath string) error { var gormLogger logger.Interface if config.IsDebug() { - gormLogger = logger.Default + gormLogger = logger.New( + log.New(os.Stdout, "\r\n", log.LstdFlags), + logger.Config{ + SlowThreshold: time.Second, + LogLevel: logger.Info, + IgnoreRecordNotFoundError: true, + Colorful: true, + }, + ) } else { gormLogger = logger.Discard }