Error logging improvements (#3768)

* Improve auto-tag error messages
* Ignore another context canceled error
* Ignore more graphql context canceled errors
This commit is contained in:
DingDongSoLong4
2023-05-26 01:49:00 +02:00
committed by GitHub
parent 62b6457f4e
commit cc9ded05a3
3 changed files with 136 additions and 103 deletions

View File

@@ -11,27 +11,29 @@ import (
)
func gqlErrorHandler(ctx context.Context, e error) *gqlerror.Error {
// log all errors - for now just log the error message
// we can potentially add more context later
fc := graphql.GetFieldContext(ctx)
if fc != nil && !errors.Is(e, context.Canceled) {
logger.Errorf("%s: %v", fc.Path(), e)
if !errors.Is(ctx.Err(), context.Canceled) {
// log all errors - for now just log the error message
// we can potentially add more context later
fc := graphql.GetFieldContext(ctx)
if fc != nil {
logger.Errorf("%s: %v", fc.Path(), e)
// log the args in debug level
logger.DebugFunc(func() (string, []interface{}) {
var args interface{}
args = fc.Args
// log the args in debug level
logger.DebugFunc(func() (string, []interface{}) {
var args interface{}
args = fc.Args
s, _ := json.Marshal(args)
if len(s) > 0 {
args = string(s)
}
s, _ := json.Marshal(args)
if len(s) > 0 {
args = string(s)
}
return "%s: %v", []interface{}{
fc.Path(),
args,
}
})
return "%s: %v", []interface{}{
fc.Path(),
args,
}
})
}
}
// we may also want to transform the error message for the response