- 将高密度服务与处理器日志迁移到新日志系统(LegacyPrintf/结构化日志) - 增加 stdlog bridge 与兼容测试,保留旧日志捕获能力 - 将 OpenAI 断流告警改为结构化 Warn 并改造对应测试为 sink 捕获 - 补齐后端相关文件 logger 引用并通过全量 go test
20 lines
457 B
Go
20 lines
457 B
Go
package handler
|
|
|
|
import (
|
|
"github.com/Wei-Shaw/sub2api/internal/pkg/logger"
|
|
"github.com/gin-gonic/gin"
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
func requestLogger(c *gin.Context, component string, fields ...zap.Field) *zap.Logger {
|
|
base := logger.L()
|
|
if c != nil && c.Request != nil {
|
|
base = logger.FromContext(c.Request.Context())
|
|
}
|
|
|
|
if component != "" {
|
|
fields = append([]zap.Field{zap.String("component", component)}, fields...)
|
|
}
|
|
return base.With(fields...)
|
|
}
|