视频保存

This commit is contained in:
duoaohui
2026-05-19 16:15:01 +08:00
parent b158cccbfc
commit 3fe284ec5c
4 changed files with 17 additions and 4 deletions

View File

@@ -3,6 +3,7 @@ package db
import (
"context"
"errors"
"fmt"
"time"
@@ -43,6 +44,12 @@ func (l *zapGormLogger) Trace(ctx context.Context, begin time.Time, fc func() (s
zap.String("sql", sql),
}
if err != nil {
// gorm.ErrRecordNotFound 在业务侧大量被用作"是否存在"判定GetByXxx 返回 nil, nil
// 没必要在 SQL 层把它当 ERROR 刷出来,否则会误触告警;保持原 fields 在 Debug 层级即可排障
if errors.Is(err, gorm.ErrRecordNotFound) {
logs.Debug(ctx, "gorm.trace", "SQL未命中record not found", fields...)
return
}
fields = append(fields, zap.Error(err))
logs.Error(ctx, "gorm.trace", "SQL执行失败", fields...)
return