From 3109e1447aeca5d553061894d6e45bc860cde761 Mon Sep 17 00:00:00 2001 From: Yusef Mohamadi Date: Thu, 9 Nov 2023 16:08:12 +0100 Subject: [PATCH] support adding fields to already exists fields (#13) --- 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) }