fix(slog-fields)

- err record not found currectly ignored
This commit is contained in:
Reza Mokaram 2025-07-28 12:20:16 +03:30
parent 02f4f1c49c
commit a481f64abe

View File

@ -66,12 +66,10 @@ func (l *slogLogger) Trace(ctx context.Context, begin time.Time, fc func() (sql
if rows != -1 {
fields = append(fields, slog.Int64("rows", rows))
}
if err != nil {
fields = append(fields, slog.String("error", err.Error()))
}
switch {
case err != nil && (!l.IgnoreRecordNotFoundError || !errors.Is(err, ErrRecordNotFound)):
fields = append(fields, slog.String("error", err.Error()))
l.Logger.ErrorContext(ctx, "SQL executed", slog.Attr{
Key: "trace",
Value: slog.GroupValue(fields...),