fix: dont log ErrRecordNotFound messages

This commit is contained in:
Derrick Hammer 2024-02-24 08:44:34 -05:00
parent f6f9a7f97a
commit fb8dfb2fa2
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 7 additions and 0 deletions

View File

@ -2,9 +2,12 @@ package db
import (
"context"
"errors"
"strconv"
"time"
"gorm.io/gorm"
"go.uber.org/zap"
dbLogger "gorm.io/gorm/logger"
)
@ -49,6 +52,10 @@ func (l logger) Error(ctx context.Context, s string, i ...interface{}) {
func (l logger) Trace(ctx context.Context, begin time.Time, fc func() (sql string, rowsAffected int64), err error) {
if l.level.Level() <= zap.DebugLevel {
if errors.Is(err, gorm.ErrRecordNotFound) {
return
}
sql, rowsAffected := fc()
fields := []zap.Field{
zap.String("sql", sql),