This commit is contained in:
Jeroen Saey
2026-01-26 06:45:05 +01:00
parent 521feac8a9
commit 123b90f559
5 changed files with 15 additions and 17 deletions

View File

@@ -23,7 +23,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<EVRevisionFormat>1.5.4+{chash:10}.{c:ymd}</EVRevisionFormat> <EVRevisionFormat>1.5.5+{chash:10}.{c:ymd}</EVRevisionFormat>
<EVDefault>true</EVDefault> <EVDefault>true</EVDefault>
<EVInfo>true</EVInfo> <EVInfo>true</EVInfo>
<EVTagMatch>v[0-9]*</EVTagMatch> <EVTagMatch>v[0-9]*</EVTagMatch>

View File

@@ -158,7 +158,7 @@ namespace EonaCat.Logger.EonaCatCoreLogger
} }
} }
private static DbParameter CreateParameter(DbCommand command, string name, object value) private DbParameter CreateParameter(DbCommand command, string name, object value)
{ {
var param = command.CreateParameter(); var param = command.CreateParameter();
param.ParameterName = $"@{name}"; param.ParameterName = $"@{name}";

View File

@@ -16,12 +16,12 @@ namespace EonaCat.Logger.EonaCatCoreLogger
private readonly DatabaseLoggerOptions _options; private readonly DatabaseLoggerOptions _options;
private readonly LoggerScopedContext _context = new(); private readonly LoggerScopedContext _context = new();
private static readonly ConcurrentQueue<LogEntry> _queue = new(); private readonly ConcurrentQueue<LogEntry> _queue = new();
private static readonly SemaphoreSlim _flushLock = new(1, 1); private readonly SemaphoreSlim _flushLock = new(1, 1);
private static CancellationTokenSource _cts = new(); private CancellationTokenSource _cts = new();
private static Task _flushTask; private Task _flushTask;
private static int _refCount; private int _refCount;
private const int MaxQueueSize = 10_000; private const int MaxQueueSize = 10_000;

View File

@@ -16,14 +16,13 @@ namespace EonaCat.Logger.EonaCatCoreLogger
private readonly DiscordLoggerOptions _options; private readonly DiscordLoggerOptions _options;
private readonly LoggerScopedContext _context = new LoggerScopedContext(); private readonly LoggerScopedContext _context = new LoggerScopedContext();
// Static shared resources private readonly HttpClient _httpClient = new HttpClient();
private static readonly HttpClient _httpClient = new HttpClient(); private readonly SemaphoreSlim _flushLock = new SemaphoreSlim(1, 1);
private static readonly SemaphoreSlim _flushLock = new SemaphoreSlim(1, 1); private readonly ConcurrentQueue<string> _messageQueue = new ConcurrentQueue<string>();
private static readonly ConcurrentQueue<string> _messageQueue = new ConcurrentQueue<string>();
private static bool _flushLoopStarted = false; private bool _flushLoopStarted = false;
private static CancellationTokenSource _cts; private CancellationTokenSource _cts;
private static Task _flushTask; private Task _flushTask;
public bool IncludeCorrelationId { get; set; } public bool IncludeCorrelationId { get; set; }
public event EventHandler<Exception> OnException; public event EventHandler<Exception> OnException;
@@ -157,8 +156,7 @@ namespace EonaCat.Logger.EonaCatCoreLogger
} }
} }
// Optional: call this on app shutdown public void Shutdown()
public static void Shutdown()
{ {
_cts?.Cancel(); _cts?.Cancel();
try try

View File

@@ -171,7 +171,7 @@ namespace EonaCat.Logger.EonaCatCoreLogger
} }
} }
private static string ReplaceTemplate(string template, Dictionary<string, string> values) private string ReplaceTemplate(string template, Dictionary<string, string> values)
{ {
foreach (var kv in values) foreach (var kv in values)
{ {