v0.0.253
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Failing after 1m23s
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Failing after 1m23s
This commit is contained in:
@@ -4,7 +4,10 @@ import (
|
||||
"github.com/rs/xid"
|
||||
"github.com/rs/zerolog"
|
||||
"gogs.mikescher.com/BlackForestBytes/goext/langext"
|
||||
"gogs.mikescher.com/BlackForestBytes/goext/rext"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
@@ -77,7 +80,10 @@ func (ee *ExErr) As(target any) bool {
|
||||
}
|
||||
|
||||
func (ee *ExErr) Log(evt *zerolog.Event) {
|
||||
backup := zerolog.CallerMarshalFunc
|
||||
zerolog.CallerMarshalFunc = customZerologCallerMarshalFunc
|
||||
evt.Msg(ee.FormatLog(LogPrintFull))
|
||||
zerolog.CallerMarshalFunc = backup
|
||||
}
|
||||
|
||||
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) {
|
||||
backup := zerolog.CallerMarshalFunc
|
||||
zerolog.CallerMarshalFunc = customZerologCallerMarshalFunc
|
||||
ee.Meta.Apply(evt).Msg(ee.FormatLog(LogPrintShort))
|
||||
zerolog.CallerMarshalFunc = backup
|
||||
}
|
||||
|
||||
// RecursiveMessage returns the message to show
|
||||
@@ -296,3 +305,10 @@ func (ee *ExErr) equalsDirectProperties(other *ExErr) bool {
|
||||
func newID() 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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user