重构日志与可观测性体系
新增单行文本编码器与结构化 GORM 日志,统一错误记录与请求日志策略,收紧日志文件权限并修复按天切分与压缩,支付回调参数脱敏,生产强制阿里云短信,RequestID 校验防注入,日志文案中文化。
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
|
||||
"hfb_sys/backend/internal/captcha"
|
||||
smsprovider "hfb_sys/backend/internal/integrations/sms"
|
||||
"hfb_sys/backend/internal/logging"
|
||||
"hfb_sys/backend/internal/model"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
@@ -120,7 +121,15 @@ func (s *Service) SendSMSCode(ctx context.Context, phone string, captchaID strin
|
||||
}
|
||||
if err := s.sms.SendLoginCode(ctx, phone, code); err != nil {
|
||||
if s.log != nil {
|
||||
s.log.Warn("sms login code send failed", zap.String("phone", PublicPhone(phone)), zap.Error(err))
|
||||
fields := []zap.Field{
|
||||
zap.String("module", "auth"),
|
||||
zap.String("phone", PublicPhone(phone)),
|
||||
zap.Error(err),
|
||||
}
|
||||
if requestID := logging.RequestIDFromContext(ctx); requestID != "" {
|
||||
fields = append(fields, zap.String("request_id", requestID))
|
||||
}
|
||||
s.log.Warn("短信验证码发送失败", fields...)
|
||||
}
|
||||
if smsprovider.IsProviderRateLimited(err) {
|
||||
pipe := s.redis.TxPipeline()
|
||||
|
||||
Reference in New Issue
Block a user