fix: dont log ErrRecordNotFound messages
This commit is contained in:
parent
f6f9a7f97a
commit
fb8dfb2fa2
|
@ -2,9 +2,12 @@ package db
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"gorm.io/gorm"
|
||||||
|
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
dbLogger "gorm.io/gorm/logger"
|
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) {
|
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 l.level.Level() <= zap.DebugLevel {
|
||||||
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
sql, rowsAffected := fc()
|
sql, rowsAffected := fc()
|
||||||
fields := []zap.Field{
|
fields := []zap.Field{
|
||||||
zap.String("sql", sql),
|
zap.String("sql", sql),
|
||||||
|
|
Loading…
Reference in New Issue