Skip to content

Commit

Permalink
support adding fields to already exists fields (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuseferi authored Nov 9, 2023
1 parent d142945 commit 3109e14
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions zax.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ const loggerKey = Key("zax")

// Set Add passed fields in context
func Set(ctx context.Context, fields []zap.Field) context.Context {
if loggerFields, ok := ctx.Value(loggerKey).([]zap.Field); ok {
fields = append(fields, loggerFields...)
}
return context.WithValue(ctx, loggerKey, fields)
}

Expand Down

0 comments on commit 3109e14

Please sign in to comment.