v0.0.445 added CtxData() and ExtendGinMeta/ExtendContextMeta to exerr
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 1m55s
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 1m55s
This commit is contained in:
@@ -68,10 +68,11 @@ func init() {
|
||||
}
|
||||
|
||||
type Builder struct {
|
||||
wrappedErr error
|
||||
errorData *ExErr
|
||||
containsGinData bool
|
||||
noLog bool
|
||||
wrappedErr error
|
||||
errorData *ExErr
|
||||
containsGinData bool
|
||||
containsContextData bool
|
||||
noLog bool
|
||||
}
|
||||
|
||||
func Get(err error) *Builder {
|
||||
@@ -365,10 +366,20 @@ func (b *Builder) GinReq(ctx context.Context, g *gin.Context, req *http.Request)
|
||||
|
||||
}
|
||||
|
||||
pkgconfig.ExtendGinMeta(ctx, b, g, req)
|
||||
|
||||
b.containsGinData = true
|
||||
return b
|
||||
}
|
||||
|
||||
func (b *Builder) CtxData(method Method, ctx context.Context) *Builder {
|
||||
pkgconfig.ExtendContextMeta(b, method, ctx)
|
||||
|
||||
b.containsContextData = true
|
||||
|
||||
return b
|
||||
}
|
||||
|
||||
func formatHeader(header map[string][]string) string {
|
||||
ml := 1
|
||||
for k, _ := range header {
|
||||
@@ -412,9 +423,13 @@ func extractHeader(header map[string][]string) []string {
|
||||
// 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 {
|
||||
func (b *Builder) Build(ctxs ...context.Context) error {
|
||||
warnOnPkgConfigNotInitialized()
|
||||
|
||||
for _, dctx := range ctxs {
|
||||
b.CtxData(MethodBuild, dctx)
|
||||
}
|
||||
|
||||
if pkgconfig.DisableErrorWrapping && b.wrappedErr != nil {
|
||||
return b.wrappedErr
|
||||
}
|
||||
@@ -439,6 +454,8 @@ func (b *Builder) Output(ctx context.Context, g *gin.Context) {
|
||||
b.GinReq(ctx, g, g.Request)
|
||||
}
|
||||
|
||||
b.CtxData(MethodOutput, ctx)
|
||||
|
||||
b.errorData.Output(g)
|
||||
|
||||
if (b.errorData.Severity == SevErr || b.errorData.Severity == SevFatal) && (pkgconfig.ZeroLogErrGinOutput || pkgconfig.ZeroLogAllGinOutput) {
|
||||
@@ -452,7 +469,13 @@ func (b *Builder) Output(ctx context.Context, g *gin.Context) {
|
||||
|
||||
// Print prints the error
|
||||
// If the error is SevErr we also send it to the error-service
|
||||
func (b *Builder) Print() {
|
||||
func (b *Builder) Print(ctxs ...context.Context) {
|
||||
warnOnPkgConfigNotInitialized()
|
||||
|
||||
for _, dctx := range ctxs {
|
||||
b.CtxData(MethodPrint, dctx)
|
||||
}
|
||||
|
||||
if b.errorData.Severity == SevErr || b.errorData.Severity == SevFatal {
|
||||
b.errorData.Log(stackSkipLogger.Error())
|
||||
} else if b.errorData.Severity == SevWarn {
|
||||
@@ -468,7 +491,12 @@ func (b *Builder) Format(level LogPrintLevel) string {
|
||||
|
||||
// Fatal prints the error and terminates the program
|
||||
// If the error is SevErr we also send it to the error-service
|
||||
func (b *Builder) Fatal() {
|
||||
func (b *Builder) Fatal(ctxs ...context.Context) {
|
||||
|
||||
for _, dctx := range ctxs {
|
||||
b.CtxData(MethodFatal, dctx)
|
||||
}
|
||||
|
||||
b.errorData.Severity = SevFatal
|
||||
b.errorData.Log(stackSkipLogger.WithLevel(zerolog.FatalLevel))
|
||||
|
||||
|
Reference in New Issue
Block a user