From 8edc3c70d33530c9628270b2e26e41dfe38fb687 Mon Sep 17 00:00:00 2001 From: Jon Kazama Date: Wed, 13 May 2026 08:11:34 +0200 Subject: [PATCH] feat(util): add IPluginLogProxy interface and production wrapper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit F12.2 closes the gap that F12.1 left open: MessageStore's ctor calls Plugin.Log.Information inside Migrate0, which prevents an isolated xUnit construction test (Dalamud.dll cannot load in the test AppDomain). The proxy mirrors IPluginLog's full surface (Verbose/Debug/Information/ Info/Warning/Error/Fatal — both Info and Information as Dalamud exposes them) with both single-string and Exception+string overloads, so the ~91 existing Plugin.Log.* call-sites become a drop-in rewrite to Plugin.LogProxy.*. A later DI-container adoption cycle (v1.5.x) may swap this for Microsoft.Extensions.Logging's ILogger; this commit is the intermediate decorator step. --- HellionChat/Plugin.cs | 6 ++++ HellionChat/Util/DalamudPluginLogProxy.cs | 40 +++++++++++++++++++++++ HellionChat/Util/IPluginLogProxy.cs | 33 +++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 HellionChat/Util/DalamudPluginLogProxy.cs create mode 100644 HellionChat/Util/IPluginLogProxy.cs diff --git a/HellionChat/Plugin.cs b/HellionChat/Plugin.cs index 2863e82..262691d 100755 --- a/HellionChat/Plugin.cs +++ b/HellionChat/Plugin.cs @@ -117,6 +117,11 @@ public sealed class Plugin : IAsyncDalamudPlugin // any service allocated in LoadAsync can read Plugin.PlatformUtil. internal static IPlatformUtil PlatformUtil { get; private set; } = null!; + // Log indirection over Dalamud's IPluginLog. Same rationale as PlatformUtil: + // call-sites read through LogProxy so MessageStore can be tested in + // isolation. Wired immediately after Dalamud injects Log. + internal static IPluginLogProxy LogProxy { get; private set; } = null!; + // Idempotency guard — Dalamud may fire DisposeAsync twice in a reload race. private int _disposeStarted; @@ -162,6 +167,7 @@ public sealed class Plugin : IAsyncDalamudPlugin // needs Util.* — services then read Plugin.PlatformUtil instead of // hitting the Dalamud static surface directly. PlatformUtil = new DalamudPlatformUtil(); + LogProxy = new DalamudPluginLogProxy(Log); // Schema gate: v1.4.x requires config v16. Users on older schemas // must install v1.4.2 first to run the migration chain. diff --git a/HellionChat/Util/DalamudPluginLogProxy.cs b/HellionChat/Util/DalamudPluginLogProxy.cs new file mode 100644 index 0000000..00e4347 --- /dev/null +++ b/HellionChat/Util/DalamudPluginLogProxy.cs @@ -0,0 +1,40 @@ +using System; +using Dalamud.Plugin.Services; + +namespace HellionChat.Util; + +internal sealed class DalamudPluginLogProxy : IPluginLogProxy +{ + private readonly IPluginLog _log; + + public DalamudPluginLogProxy(IPluginLog log) => _log = log; + + public void Verbose(string message) => _log.Verbose(message); + + public void Verbose(Exception exception, string message) => _log.Verbose(exception, message); + + public void Debug(string message) => _log.Debug(message); + + public void Debug(Exception exception, string message) => _log.Debug(exception, message); + + public void Information(string message) => _log.Information(message); + + public void Information(Exception exception, string message) => + _log.Information(exception, message); + + public void Info(string message) => _log.Info(message); + + public void Info(Exception exception, string message) => _log.Info(exception, message); + + public void Warning(string message) => _log.Warning(message); + + public void Warning(Exception exception, string message) => _log.Warning(exception, message); + + public void Error(string message) => _log.Error(message); + + public void Error(Exception exception, string message) => _log.Error(exception, message); + + public void Fatal(string message) => _log.Fatal(message); + + public void Fatal(Exception exception, string message) => _log.Fatal(exception, message); +} diff --git a/HellionChat/Util/IPluginLogProxy.cs b/HellionChat/Util/IPluginLogProxy.cs new file mode 100644 index 0000000..630b5e5 --- /dev/null +++ b/HellionChat/Util/IPluginLogProxy.cs @@ -0,0 +1,33 @@ +using System; + +namespace HellionChat.Util; + +// Indirection over Dalamud's IPluginLog so MessageStore can be constructed +// in an isolated xUnit AppDomain without loading Dalamud.dll — same pattern +// as IPlatformUtil from F12.1. A later DI-container cycle (v1.5.x) may +// replace this with Microsoft.Extensions.Logging's ILogger. +internal interface IPluginLogProxy +{ + void Verbose(string message); + void Verbose(Exception exception, string message); + + void Debug(string message); + void Debug(Exception exception, string message); + + void Information(string message); + void Information(Exception exception, string message); + + // IPluginLog exposes Info as a distinct method (short alias of + // Information) — both are present so call-sites stay drop-in. + void Info(string message); + void Info(Exception exception, string message); + + void Warning(string message); + void Warning(Exception exception, string message); + + void Error(string message); + void Error(Exception exception, string message); + + void Fatal(string message); + void Fatal(Exception exception, string message); +}