Compare commits

...

4 Commits

Author SHA1 Message Date
9e5bc0d3ea v0.0.253
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Failing after 1m23s
2023-08-22 10:36:35 +02:00
6d3bd13f61 v0.0.252
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Failing after 1m5s
2023-08-22 10:23:04 +02:00
b5ca475b3f v0.0.251 exerr.WithStackSkip
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 1m9s
2023-08-22 10:21:13 +02:00
a75b1291cb v0.0.250
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Failing after 51s
2023-08-21 15:34:27 +02:00
4 changed files with 29 additions and 4 deletions

View File

@@ -112,6 +112,13 @@ func (b *Builder) WithMessage(msg string) *Builder {
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
func (b *Builder) WithStackSkip(stacktraceskip int) *Builder {
b.errorData.Caller = callername(stacktraceskip)
return b
}
// ----------------------------------------------------------------------------
// Err changes the Severity to ERROR (default) // Err changes the Severity to ERROR (default)
// The error will be: // The error will be:
// //

View File

@@ -4,7 +4,10 @@ import (
"github.com/rs/xid" "github.com/rs/xid"
"github.com/rs/zerolog" "github.com/rs/zerolog"
"gogs.mikescher.com/BlackForestBytes/goext/langext" "gogs.mikescher.com/BlackForestBytes/goext/langext"
"gogs.mikescher.com/BlackForestBytes/goext/rext"
"reflect" "reflect"
"regexp"
"strconv"
"strings" "strings"
"time" "time"
) )
@@ -77,7 +80,10 @@ func (ee *ExErr) As(target any) bool {
} }
func (ee *ExErr) Log(evt *zerolog.Event) { func (ee *ExErr) Log(evt *zerolog.Event) {
backup := zerolog.CallerMarshalFunc
zerolog.CallerMarshalFunc = customZerologCallerMarshalFunc
evt.Msg(ee.FormatLog(LogPrintFull)) evt.Msg(ee.FormatLog(LogPrintFull))
zerolog.CallerMarshalFunc = backup
} }
func (ee *ExErr) FormatLog(lvl LogPrintLevel) string { func (ee *ExErr) FormatLog(lvl LogPrintLevel) string {
@@ -164,7 +170,10 @@ func (ee *ExErr) FormatLog(lvl LogPrintLevel) string {
} }
func (ee *ExErr) ShortLog(evt *zerolog.Event) { func (ee *ExErr) ShortLog(evt *zerolog.Event) {
backup := zerolog.CallerMarshalFunc
zerolog.CallerMarshalFunc = customZerologCallerMarshalFunc
ee.Meta.Apply(evt).Msg(ee.FormatLog(LogPrintShort)) ee.Meta.Apply(evt).Msg(ee.FormatLog(LogPrintShort))
zerolog.CallerMarshalFunc = backup
} }
// RecursiveMessage returns the message to show // RecursiveMessage returns the message to show
@@ -296,3 +305,10 @@ func (ee *ExErr) equalsDirectProperties(other *ExErr) bool {
func newID() string { func newID() string {
return xid.New().String() return xid.New().String()
} }
var regexZerologCallerClean = rext.W(regexp.MustCompile(`^(\.\./)*/?go/pkg/mod/gogs\.(mikescher|blackforestbytes)\.(com|de)/!black!forest!bytes/?`))
func customZerologCallerMarshalFunc(pc uintptr, file string, line int) string {
file = regexZerologCallerClean.ReplaceAll(file, "", true)
return file + ":" + strconv.Itoa(line)
}

View File

@@ -5,7 +5,6 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"github.com/gin-gonic/gin"
"github.com/rs/zerolog" "github.com/rs/zerolog"
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/bson/primitive"
@@ -616,9 +615,12 @@ func (v MetaValue) rawValueForJson() any {
if v.Value.(AnyWrap).IsError { if v.Value.(AnyWrap).IsError {
return bson.M{"@error": true} return bson.M{"@error": true}
} }
jsonobj := gin.H{} jsonobj := primitive.M{}
jsonarr := primitive.A{}
if err := json.Unmarshal([]byte(v.Value.(AnyWrap).Json), &jsonobj); err == nil { if err := json.Unmarshal([]byte(v.Value.(AnyWrap).Json), &jsonobj); err == nil {
return jsonobj return jsonobj
} else if err := json.Unmarshal([]byte(v.Value.(AnyWrap).Json), &jsonarr); err == nil {
return jsonarr
} else { } else {
return bson.M{"type": v.Value.(AnyWrap).Type, "data": v.Value.(AnyWrap).Json} return bson.M{"type": v.Value.(AnyWrap).Type, "data": v.Value.(AnyWrap).Json}
} }

View File

@@ -1,5 +1,5 @@
package goext package goext
const GoextVersion = "0.0.249" const GoextVersion = "0.0.253"
const GoextVersionTimestamp = "2023-08-21T15:19:40+0200" const GoextVersionTimestamp = "2023-08-22T10:36:35+0200"