feat(platform): 日志管理 - 统一日志出口并屏蔽查询与 Agent 流式事件日志

新增 internal/logging,slog、标准库 log、GORM 与 Gin 访问日志共用同一 Handler,由 CANVAS_LOG_LEVEL / CANVAS_LOG_FORMAT 控制。info 级别不再输出成功的查询类请求、成功 SQL、message_end 等 Agent 流式事件和常规画布自动保存;4xx/5xx、慢请求、慢 SQL、SQL 失败与 panic 仍会记录,SQL 不内联参数值。
This commit is contained in:
ddcat666 committed 2026-09-30 03:33:34 +08:00
1 parent b7ff958c2d
commit a0f025aa96
21 files changed
+602 -44

No files matched your search

+9 -3
View File
@@ -3,8 +3,10 @@ package app
import (
"encoding/json"
"fmt"
"log"
"log/slog"
"time"
"infinite-canvas/backend/internal/logging"
"infinite-canvas/backend/internal/model"
)
@@ -111,7 +113,9 @@ func (s *Service) publicSystemChannelCatalog(intent *ModelRequestIntent) ([]Publ
if intent != nil {
matched, matchErr := s.channelModelMatchesIntent(&cm, intent)
if matchErr != nil {
log.Printf("system channel model omitted from catalog id=%s: invalid capability: %v", cm.ID, matchErr)
if logging.Every("catalog-omit:"+cm.ID, 10*time.Minute) {
slog.Warn("system channel model omitted from catalog", "id", cm.ID, "reason", "invalid capability", "error", matchErr)
}
continue
}
if !matched {
@@ -121,7 +125,9 @@ func (s *Service) publicSystemChannelCatalog(intent *ModelRequestIntent) ([]Publ
publicModel, sanitizeErr := s.sanitizeChannelModel(&cm)
if sanitizeErr != nil {
log.Printf("system channel model omitted from catalog id=%s: %v", cm.ID, sanitizeErr)
if logging.Every("catalog-omit:"+cm.ID, 10*time.Minute) {
slog.Warn("system channel model omitted from catalog", "id", cm.ID, "error", sanitizeErr)
}
continue
}
publicModels = append(publicModels, publicModel)