diff --git a/RaygunCore.props b/RaygunCore.props
index 252f61c..8d1a9c0 100644
--- a/RaygunCore.props
+++ b/RaygunCore.props
@@ -6,7 +6,7 @@
https://github.com/anfomin/rayguncore
https://github.com/anfomin/rayguncore
LICENSE
- 2.2.0
+ 2.3.0
$(VERSION_SUFFIX)
$(NoWarn);1573;1591
true
diff --git a/RaygunCore/Services/DefaultRaygunClient.cs b/RaygunCore/Services/DefaultRaygunClient.cs
index 5671ca5..2dc0eed 100644
--- a/RaygunCore/Services/DefaultRaygunClient.cs
+++ b/RaygunCore/Services/DefaultRaygunClient.cs
@@ -31,8 +31,12 @@ public DefaultRaygunClient(
}
///
- public async Task SendAsync(string message, Exception? exception, RaygunSeverity? severity = null, IEnumerable? tags = null, IDictionary? customData = null)
- {
+ public async Task SendAsync(string message,
+ Exception? exception,
+ RaygunSeverity? severity = null,
+ IEnumerable? tags = null,
+ IDictionary? customData = null
+ ) {
if (_options.Tags.Count > 0)
tags = tags == null ? _options.Tags : tags.Concat(_options.Tags).Distinct();
diff --git a/RaygunCore/Services/RaygunLogger.cs b/RaygunCore/Services/RaygunLogger.cs
index 7092f0a..31824ee 100644
--- a/RaygunCore/Services/RaygunLogger.cs
+++ b/RaygunCore/Services/RaygunLogger.cs
@@ -12,9 +12,13 @@ public class RaygunLogger : ILogger
public static IEnumerable RunningTasks => _runningTasks;
readonly Lazy _client;
+ readonly string? _category;
- public RaygunLogger(Lazy client)
- => _client = client ?? throw new ArgumentNullException(nameof(client));
+ public RaygunLogger(Lazy client, string? category = null)
+ {
+ _client = client ?? throw new ArgumentNullException(nameof(client));
+ _category = category;
+ }
///
/// Scopes not implemeted.
@@ -24,7 +28,8 @@ public RaygunLogger(Lazy client)
=> null;
///
- public bool IsEnabled(LogLevel logLevel) => logLevel >= LogLevel.Warning;
+ public bool IsEnabled(LogLevel logLevel)
+ => logLevel >= LogLevel.Warning;
///
public void Log(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func formatter)
@@ -36,7 +41,14 @@ public void Log(LogLevel logLevel, EventId eventId, TState state, Except
var message = formatter(state, exception);
if (!string.IsNullOrEmpty(message) || exception != null)
{
- var task = _client.Value.SendAsync(message, exception, GetSeverity(logLevel));
+ var task = _client.Value.SendAsync(message, exception,
+ severity: GetSeverity(logLevel),
+ tags: _category == null ? null : new[] { _category },
+ customData: eventId == default ? null : new Dictionary()
+ {
+ ["EventId"] = eventId
+ }
+ );
if (!task.IsCompleted)
_runningTasks.Add(task);
task.ContinueWith(task => _runningTasks.Remove(task));
diff --git a/RaygunCore/Services/RaygunLoggerProvider.cs b/RaygunCore/Services/RaygunLoggerProvider.cs
index 74facc9..5c27e56 100644
--- a/RaygunCore/Services/RaygunLoggerProvider.cs
+++ b/RaygunCore/Services/RaygunLoggerProvider.cs
@@ -8,18 +8,18 @@ namespace RaygunCore.Services;
///
public class RaygunLoggerProvider : ILoggerProvider
{
- readonly IServiceProvider _services;
+ readonly Lazy _clientLazy;
public RaygunLoggerProvider(IServiceProvider services)
- => _services = services ?? throw new ArgumentNullException(nameof(services));
-
- ///
- public ILogger CreateLogger(string categoryName)
{
// using Lazy because IHttpClientFactory requires logger and DI fails with dependency recursion
- return new RaygunLogger(new Lazy(() => _services.GetRequiredService()));
+ _clientLazy = new Lazy(() => services.GetRequiredService());
}
+ ///
+ public ILogger CreateLogger(string categoryName)
+ => new RaygunLogger(_clientLazy, categoryName);
+
///
public void Dispose() { }
}
\ No newline at end of file