From 671f0f4226a655564eea3700b1fd44704ae39c32 Mon Sep 17 00:00:00 2001 From: Yusef Mohamadi Date: Thu, 9 Nov 2023 16:07:02 +0100 Subject: [PATCH] support adding fields to already exists fields --- zax.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/zax.go b/zax.go index 7c430e6..644a6a0 100644 --- a/zax.go +++ b/zax.go @@ -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) }