Skip to content

Commit

Permalink
Don't log validation errors as errors in memstore
Browse files Browse the repository at this point in the history
It's never been useful, and just logs stuff like "Hit.Defaults: path:
must be shorter than 2048 characters." – that should really be info or
debug logs.
  • Loading branch information
arp242 committed Dec 10, 2023
1 parent b8fed0a commit e348331
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion memstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"crypto/sha256"
"encoding"
"encoding/base64"
"errors"
"fmt"
"net/url"
"slices"
Expand All @@ -24,6 +25,8 @@ import (
"zgo.at/zstd/zcrypto"
"zgo.at/zstd/zint"
"zgo.at/zstd/ztime"
"zgo.at/zstd/ztype"
"zgo.at/zvalidate"
)

var (
Expand Down Expand Up @@ -291,7 +294,11 @@ func (m *ms) processHit(ctx context.Context, h *Hit) bool {

err = h.Defaults(ctx, false)
if err != nil {
l.Field("hit", fmt.Sprintf("%#v", h)).Error(err)
if errors.As(err, ztype.Ptr(&zvalidate.Validator{})) {
l.Field("hit", fmt.Sprintf("%#v", h)).Error(err)
} else {
l.Field("hit", fmt.Sprintf("%#v", h)).Debug(err)
}
return false
}

Expand Down

0 comments on commit e348331

Please sign in to comment.