Skip to content

fix: logging null reference when batch processing #521

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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