From 123b90f559446fe09bb2a5119bfccccc888d2e08 Mon Sep 17 00:00:00 2001 From: Jeroen Saey Date: Mon, 26 Jan 2026 06:45:05 +0100 Subject: [PATCH] Updated --- EonaCat.Logger/EonaCat.Logger.csproj | 2 +- .../EonaCatCoreLogger/BatchingDatabaseLogger.cs | 2 +- .../EonaCatCoreLogger/DatabaseLogger.cs | 10 +++++----- .../EonaCatCoreLogger/DiscordLogger.cs | 16 +++++++--------- .../EonaCatCoreLogger/ElasticSearchLogger.cs | 2 +- 5 files changed, 15 insertions(+), 17 deletions(-) diff --git a/EonaCat.Logger/EonaCat.Logger.csproj b/EonaCat.Logger/EonaCat.Logger.csproj index 87ded70..0353e87 100644 --- a/EonaCat.Logger/EonaCat.Logger.csproj +++ b/EonaCat.Logger/EonaCat.Logger.csproj @@ -23,7 +23,7 @@ - 1.5.4+{chash:10}.{c:ymd} + 1.5.5+{chash:10}.{c:ymd} true true v[0-9]* diff --git a/EonaCat.Logger/EonaCatCoreLogger/BatchingDatabaseLogger.cs b/EonaCat.Logger/EonaCatCoreLogger/BatchingDatabaseLogger.cs index 537eab4..fdc0d85 100644 --- a/EonaCat.Logger/EonaCatCoreLogger/BatchingDatabaseLogger.cs +++ b/EonaCat.Logger/EonaCatCoreLogger/BatchingDatabaseLogger.cs @@ -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(); param.ParameterName = $"@{name}"; diff --git a/EonaCat.Logger/EonaCatCoreLogger/DatabaseLogger.cs b/EonaCat.Logger/EonaCatCoreLogger/DatabaseLogger.cs index 9570ed3..2aa2167 100644 --- a/EonaCat.Logger/EonaCatCoreLogger/DatabaseLogger.cs +++ b/EonaCat.Logger/EonaCatCoreLogger/DatabaseLogger.cs @@ -16,12 +16,12 @@ namespace EonaCat.Logger.EonaCatCoreLogger private readonly DatabaseLoggerOptions _options; private readonly LoggerScopedContext _context = new(); - private static readonly ConcurrentQueue _queue = new(); - private static readonly SemaphoreSlim _flushLock = new(1, 1); + private readonly ConcurrentQueue _queue = new(); + private readonly SemaphoreSlim _flushLock = new(1, 1); - private static CancellationTokenSource _cts = new(); - private static Task _flushTask; - private static int _refCount; + private CancellationTokenSource _cts = new(); + private Task _flushTask; + private int _refCount; private const int MaxQueueSize = 10_000; diff --git a/EonaCat.Logger/EonaCatCoreLogger/DiscordLogger.cs b/EonaCat.Logger/EonaCatCoreLogger/DiscordLogger.cs index 1766667..9a5f29d 100644 --- a/EonaCat.Logger/EonaCatCoreLogger/DiscordLogger.cs +++ b/EonaCat.Logger/EonaCatCoreLogger/DiscordLogger.cs @@ -16,14 +16,13 @@ namespace EonaCat.Logger.EonaCatCoreLogger private readonly DiscordLoggerOptions _options; private readonly LoggerScopedContext _context = new LoggerScopedContext(); - // Static shared resources - private static readonly HttpClient _httpClient = new HttpClient(); - private static readonly SemaphoreSlim _flushLock = new SemaphoreSlim(1, 1); - private static readonly ConcurrentQueue _messageQueue = new ConcurrentQueue(); + private readonly HttpClient _httpClient = new HttpClient(); + private readonly SemaphoreSlim _flushLock = new SemaphoreSlim(1, 1); + private readonly ConcurrentQueue _messageQueue = new ConcurrentQueue(); - private static bool _flushLoopStarted = false; - private static CancellationTokenSource _cts; - private static Task _flushTask; + private bool _flushLoopStarted = false; + private CancellationTokenSource _cts; + private Task _flushTask; public bool IncludeCorrelationId { get; set; } public event EventHandler OnException; @@ -157,8 +156,7 @@ namespace EonaCat.Logger.EonaCatCoreLogger } } - // Optional: call this on app shutdown - public static void Shutdown() + public void Shutdown() { _cts?.Cancel(); try diff --git a/EonaCat.Logger/EonaCatCoreLogger/ElasticSearchLogger.cs b/EonaCat.Logger/EonaCatCoreLogger/ElasticSearchLogger.cs index 04726a5..78e74cc 100644 --- a/EonaCat.Logger/EonaCatCoreLogger/ElasticSearchLogger.cs +++ b/EonaCat.Logger/EonaCatCoreLogger/ElasticSearchLogger.cs @@ -171,7 +171,7 @@ namespace EonaCat.Logger.EonaCatCoreLogger } } - private static string ReplaceTemplate(string template, Dictionary values) + private string ReplaceTemplate(string template, Dictionary values) { foreach (var kv in values) {