v0.0.321 Add .NoLog() to lowest-level query exerr.Wrap in wmo (otherwise we get error logs on stdout even if the callign method allows mongo.ErrNoDocuments)
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 1m4s

This commit is contained in:
2023-11-14 16:00:14 +01:00
parent 8528b5cb66
commit 88642770c5
4 changed files with 22 additions and 12 deletions

View File

@@ -70,6 +70,7 @@ func init() {
type Builder struct {
errorData *ExErr
containsGinData bool
noLog bool
}
func Get(err error) *Builder {
@@ -190,6 +191,13 @@ func (b *Builder) System() *Builder {
// ----------------------------------------------------------------------------
func (b *Builder) NoLog() *Builder {
b.noLog = true
return b
}
// ----------------------------------------------------------------------------
func (b *Builder) Id(key string, val fmt.Stringer) *Builder {
return b.addMeta(key, MDTID, newIDWrap(val))
}
@@ -401,12 +409,14 @@ func extractHeader(header map[string][]string) []string {
// Build creates a new error, ready to pass up the stack
// If the errors is not SevWarn or SevInfo it gets also logged (in short form, without stacktrace) onto stdout
// Can be gloablly configured with ZeroLogErrTraces and ZeroLogAllTraces
// Can be locally suppressed with Builder.NoLog()
func (b *Builder) Build() error {
warnOnPkgConfigNotInitialized()
if pkgconfig.ZeroLogErrTraces && (b.errorData.Severity == SevErr || b.errorData.Severity == SevFatal) {
if pkgconfig.ZeroLogErrTraces && !b.noLog && (b.errorData.Severity == SevErr || b.errorData.Severity == SevFatal) {
b.errorData.ShortLog(stackSkipLogger.Error())
} else if pkgconfig.ZeroLogAllTraces {
} else if pkgconfig.ZeroLogAllTraces && !b.noLog {
b.errorData.ShortLog(stackSkipLogger.Error())
}