Skip to content

Commit

Permalink
get_field_values
Browse files Browse the repository at this point in the history
  • Loading branch information
fsamin committed Feb 28, 2022
1 parent 95b83ad commit 0ce02c5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions log.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,14 @@ func ErrorWithStackTrace(ctx context.Context, err error) {
ctx = ContextWithStackTrace(ctx, err)
call(ctx, LevelError, 2, err.Error())
}

func FieldValues(ctx context.Context) map[Field]interface{} {
res := make(map[Field]interface{}, 10)
for _, k := range registeredFields {
v := ctx.Value(k)
if v != nil {
res[k] = v
}
}
return res
}

0 comments on commit 0ce02c5

Please sign in to comment.