From 888aa193672cf2dc74464c589d60071b9a6ad5a2 Mon Sep 17 00:00:00 2001 From: Henrique Graca <999396+hjgraca@users.noreply.github.com> Date: Thu, 16 Nov 2023 16:47:59 +0000 Subject: [PATCH 1/2] fix logging null reference --- .../Internal/PowertoolsLogger.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libraries/src/AWS.Lambda.Powertools.Logging/Internal/PowertoolsLogger.cs b/libraries/src/AWS.Lambda.Powertools.Logging/Internal/PowertoolsLogger.cs index 27d7d613..e723ed22 100644 --- a/libraries/src/AWS.Lambda.Powertools.Logging/Internal/PowertoolsLogger.cs +++ b/libraries/src/AWS.Lambda.Powertools.Logging/Internal/PowertoolsLogger.cs @@ -40,6 +40,11 @@ internal sealed class PowertoolsLogger : ILogger /// The name /// private readonly string _name; + + /// + /// The current configuration + /// + private LoggerConfiguration _currentConfig; /// /// The Powertools for AWS Lambda (.NET) configurations @@ -77,7 +82,7 @@ public PowertoolsLogger( powertoolsConfigurations, systemWrapper, getCurrentConfig); _powertoolsConfigurations.SetExecutionEnvironment(this); - CurrentConfig = GetCurrentConfig(); + _currentConfig = GetCurrentConfig(); if (_lambdaLogLevelEnabled && _logLevel < _lambdaLogLevel) { @@ -87,7 +92,7 @@ public PowertoolsLogger( } } - private LoggerConfiguration CurrentConfig { get; set; } + private LoggerConfiguration CurrentConfig => _currentConfig ??= GetCurrentConfig(); /// /// Sets the minimum level. @@ -370,7 +375,7 @@ private object GetFormattedLogEntry(LogLevel logLevel, DateTime timestamp, objec /// internal void ClearConfig() { - CurrentConfig = null; + _currentConfig = null; } /// From d8c804d2d4fbce71a3b35593251ceadcac9911ab Mon Sep 17 00:00:00 2001 From: Henrique Graca <999396+hjgraca@users.noreply.github.com> Date: Thu, 16 Nov 2023 16:52:31 +0000 Subject: [PATCH 2/2] Update version --- version.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.json b/version.json index d83c948c..ebe82eef 100644 --- a/version.json +++ b/version.json @@ -1,6 +1,6 @@ { "Core": { - "Logging": "1.4.3", + "Logging": "1.4.4", "Metrics": "1.5.3", "Tracing": "1.3.2" },