Skip to content
Merged
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
14 changes: 7 additions & 7 deletions Mindscape.Raygun4Net.Extensions.Logging/RaygunLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class RaygunLogger : ILogger
private readonly string _category;
private readonly RaygunClientBase _client;
private readonly RaygunLoggerSettings _settings;
private readonly AsyncLocal<Dictionary<string, object>> _scopeData = new();
private readonly AsyncLocal<Dictionary<string, object?>> _scopeData = new();

/// <summary>
/// Initializes a new instance of the RaygunLogger.
Expand Down Expand Up @@ -67,7 +67,7 @@ public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Except
{
foreach (var item in _scopeData.Value)
{
customData[$"Scope{item.Key}"] = item.Value.ToString() ?? string.Empty;
customData[$"Scope{item.Key}"] = item.Value?.ToString() ?? string.Empty;
}
}

Expand Down Expand Up @@ -134,14 +134,14 @@ public IDisposable BeginScope<TState>(TState state)
var scopeData = _scopeData.Value;
if (scopeData == null)
{
scopeData = new Dictionary<string, object>();
scopeData = new Dictionary<string, object?>();
_scopeData.Value = scopeData;
}

// Handle different types of state
switch (state)
{
case IEnumerable<KeyValuePair<string, object>> properties:
case IEnumerable<KeyValuePair<string, object?>> properties:
foreach (var prop in properties)
{
scopeData[$"[{scopeData.Count}].{prop.Key}"] = prop.Value;
Expand All @@ -157,9 +157,9 @@ public IDisposable BeginScope<TState>(TState state)

private class RaygunLoggerScope : IDisposable
{
private readonly AsyncLocal<Dictionary<string, object>> _scopeData;
private readonly AsyncLocal<Dictionary<string, object?>> _scopeData;

public RaygunLoggerScope(AsyncLocal<Dictionary<string, object>> scopeData)
public RaygunLoggerScope(AsyncLocal<Dictionary<string, object?>> scopeData)
{
_scopeData = scopeData;
}
Expand All @@ -169,4 +169,4 @@ public void Dispose()
_scopeData.Value?.Clear();
}
}
}
}