From fb63570d0a52b070bca47226e996e5ec77b7b21d Mon Sep 17 00:00:00 2001 From: Neel Patel Date: Wed, 23 Jun 2021 18:52:49 +0530 Subject: [PATCH 1/3] externalId added to execution context logger --- context/ExecutionContext.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/context/ExecutionContext.go b/context/ExecutionContext.go index 6e7f6a9..c72a545 100644 --- a/context/ExecutionContext.go +++ b/context/ExecutionContext.go @@ -55,6 +55,14 @@ func NewExecutionContext(token *security.JwtToken, correlationID string, action Str("action", action). Str("correlationId", cid).Logger() + if len(token.ExternalID) > 0 { + executionCtxLogger.With().Str("externalId", token.ExternalID) + } + + if len(token.ExternalIDType) > 0 { + executionCtxLogger.With().Str("externalIdType", token.ExternalIDType) + } + } else { executionCtxLogger = logger.With(). Str("action", action). From b5c3b6a18bce9ccb6746eec4deece424beb616a5 Mon Sep 17 00:00:00 2001 From: Neel Patel Date: Wed, 23 Jun 2021 19:55:41 +0530 Subject: [PATCH 2/3] update executionCtxLogger to add externalId --- context/ExecutionContext.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/context/ExecutionContext.go b/context/ExecutionContext.go index c72a545..d7a8df6 100644 --- a/context/ExecutionContext.go +++ b/context/ExecutionContext.go @@ -56,11 +56,11 @@ func NewExecutionContext(token *security.JwtToken, correlationID string, action Str("correlationId", cid).Logger() if len(token.ExternalID) > 0 { - executionCtxLogger.With().Str("externalId", token.ExternalID) + executionCtxLogger = executionCtxLogger.With().Str("externalId", token.ExternalID).Logger() } if len(token.ExternalIDType) > 0 { - executionCtxLogger.With().Str("externalIdType", token.ExternalIDType) + executionCtxLogger = executionCtxLogger.With().Str("externalIdType", token.ExternalIDType).Logger() } } else { From fde43295b2c2fe2957d9302d944706c1de857381 Mon Sep 17 00:00:00 2001 From: Neel Patel Date: Wed, 23 Jun 2021 20:10:40 +0530 Subject: [PATCH 3/3] do not add external id to log if it is zero value --- context/ExecutionContext.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/context/ExecutionContext.go b/context/ExecutionContext.go index d7a8df6..d7aabac 100644 --- a/context/ExecutionContext.go +++ b/context/ExecutionContext.go @@ -55,12 +55,12 @@ func NewExecutionContext(token *security.JwtToken, correlationID string, action Str("action", action). Str("correlationId", cid).Logger() - if len(token.ExternalID) > 0 { + if len(token.ExternalID) > 0 && token.ExternalID != "00000000-0000-0000-0000-000000000000" { executionCtxLogger = executionCtxLogger.With().Str("externalId", token.ExternalID).Logger() } if len(token.ExternalIDType) > 0 { - executionCtxLogger = executionCtxLogger.With().Str("externalIdType", token.ExternalIDType).Logger() + executionCtxLogger = executionCtxLogger.With().Str("externalIdType", token.ExternalIDType).Logger() } } else {