视频保存
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user