Skip to content

Commit

Permalink
Merge pull request #521 from hjgraca/182-fix-examples-logging-batch
Browse files Browse the repository at this point in the history
fix: logging null reference when batch processing
  • Loading branch information
hjgraca authored Nov 16, 2023
2 parents 712bb96 + d8c804d commit ce0de0f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ internal sealed class PowertoolsLogger : ILogger
/// The name
/// </summary>
private readonly string _name;

/// <summary>
/// The current configuration
/// </summary>
private LoggerConfiguration _currentConfig;

/// <summary>
/// The Powertools for AWS Lambda (.NET) configurations
Expand Down Expand Up @@ -77,7 +82,7 @@ public PowertoolsLogger(
powertoolsConfigurations, systemWrapper, getCurrentConfig);

_powertoolsConfigurations.SetExecutionEnvironment(this);
CurrentConfig = GetCurrentConfig();
_currentConfig = GetCurrentConfig();

if (_lambdaLogLevelEnabled && _logLevel < _lambdaLogLevel)
{
Expand All @@ -87,7 +92,7 @@ public PowertoolsLogger(
}
}

private LoggerConfiguration CurrentConfig { get; set; }
private LoggerConfiguration CurrentConfig => _currentConfig ??= GetCurrentConfig();

/// <summary>
/// Sets the minimum level.
Expand Down Expand Up @@ -370,7 +375,7 @@ private object GetFormattedLogEntry(LogLevel logLevel, DateTime timestamp, objec
/// </summary>
internal void ClearConfig()
{
CurrentConfig = null;
_currentConfig = null;
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"Core": {
"Logging": "1.4.3",
"Logging": "1.4.4",
"Metrics": "1.5.3",
"Tracing": "1.3.2"
},
Expand Down

0 comments on commit ce0de0f

Please sign in to comment.