diff --git a/HellionChat/Commands.cs b/HellionChat/Commands.cs index dfe79c0..4298097 100755 --- a/HellionChat/Commands.cs +++ b/HellionChat/Commands.cs @@ -1,10 +1,17 @@ using Dalamud.Game.Command; +using Microsoft.Extensions.Logging; namespace HellionChat; internal sealed class Commands : IDisposable { private readonly Dictionary Registered = []; + private readonly ILogger _logger; + + public Commands(ILogger logger) + { + _logger = logger; + } public void Dispose() { @@ -52,7 +59,7 @@ internal sealed class Commands : IDisposable { if (!Registered.TryGetValue(command, out var wrapper)) { - Plugin.LogProxy.Warning($"Missing registration for command {command}"); + _logger.LogWarning($"Missing registration for command {command}"); return; } @@ -62,7 +69,7 @@ internal sealed class Commands : IDisposable } catch (Exception ex) { - Plugin.LogProxy.Error(ex, $"Error while executing command {command}"); + _logger.LogError(ex, $"Error while executing command {command}"); } } } diff --git a/HellionChat/FontManager.cs b/HellionChat/FontManager.cs index 9a25dcd..afb6f04 100644 --- a/HellionChat/FontManager.cs +++ b/HellionChat/FontManager.cs @@ -8,6 +8,12 @@ using Dalamud.Interface.Utility; namespace HellionChat; +// FontManager's two LogProxy sites both live in static methods +// (TryGetHellionFontBytes, AddFontWithFallback) that the BuildFonts pipeline +// invokes; an instance _logger field would be unreachable from those scopes. +// DI-4 Slice D leaves the class on Plugin.LogProxy and counts it under the +// "static consumers" bucket alongside EmoteCache / AutoTranslate / +// MemoryUtil / WrapperUtil. public class FontManager { internal IFontHandle Axis = null!; @@ -58,6 +64,9 @@ public class FontManager ); if (stream is null) { + // Static method has no instance _logger to reach. The resource- + // missing path is rare (only fires when the embedded font is + // stripped from the build), so Plugin.LogProxy is acceptable. Plugin.LogProxy.Warning( "Hellion font resource missing — falling back to system default font." ); @@ -236,7 +245,9 @@ public class FontManager { // Atlas-toolkit throws span IO and validation failures; routing the // wider set through the fallback keeps a corrupt font config from - // taking down the whole atlas build. + // taking down the whole atlas build. Static method has no instance + // _logger to reach (Plugin.Config-driven font swap, called from + // BuildFonts). Plugin.LogProxy.Warning( e, $"Configured {slot} font failed to load ({e.GetType().Name}), " diff --git a/HellionChat/PayloadHandler.cs b/HellionChat/PayloadHandler.cs index 6dac11a..6cda470 100755 --- a/HellionChat/PayloadHandler.cs +++ b/HellionChat/PayloadHandler.cs @@ -20,6 +20,7 @@ using HellionChat.Resources; using HellionChat.Ui; using HellionChat.Util; using Lumina.Excel.Sheets; +using Microsoft.Extensions.Logging; using Action = System.Action; using ChatTwoPartyFinderPayload = HellionChat.Util.PartyFinderPayload; using DalamudPartyFinderPayload = Dalamud.Game.Text.SeStringHandling.Payloads.PartyFinderPayload; @@ -40,9 +41,12 @@ public sealed class PayloadHandler private const uint PopupSfx = 1; - internal PayloadHandler(ChatLogWindow logWindow) + private readonly ILogger _logger; + + internal PayloadHandler(ChatLogWindow logWindow, ILogger logger) { LogWindow = logWindow; + _logger = logger; } internal void Draw() @@ -131,7 +135,7 @@ public sealed class PayloadHandler } catch (Exception ex) { - Plugin.LogProxy.Error(ex, "Error executing integration"); + _logger.LogError(ex, "Error executing integration"); } } @@ -535,7 +539,7 @@ public sealed class PayloadHandler ) ) { - Plugin.LogProxy.Warning("Could not find DalamudLinkHandlers"); + _logger.LogWarning("Could not find DalamudLinkHandlers"); return; } @@ -546,7 +550,7 @@ public sealed class PayloadHandler } catch (Exception ex) { - Plugin.LogProxy.Error(ex, "Error executing DalamudLinkPayload handler"); + _logger.LogError(ex, "Error executing DalamudLinkPayload handler"); } } diff --git a/HellionChat/PluginHostFactory.cs b/HellionChat/PluginHostFactory.cs index 7c77afc..32d5199 100644 --- a/HellionChat/PluginHostFactory.cs +++ b/HellionChat/PluginHostFactory.cs @@ -97,7 +97,7 @@ internal static class PluginHostFactory sp.GetRequiredService() )); services.AddSingleton(_ => new FileDialogManager()); - services.AddSingleton(_ => new Commands()); + services.AddSingleton(sp => new Commands(sp.GetRequiredService>())); services.AddSingleton(_ => new FontManager()); services.AddSingleton(_ => new StatusBar()); services.AddSingleton(sp => new IpcManager(sp.GetRequiredService>())); @@ -107,7 +107,8 @@ internal static class PluginHostFactory Path.Combine( sp.GetRequiredService().ConfigDirectory.FullName, "themes" - ) + ), + sp.GetRequiredService>() )); services.AddSingleton(sp => new GameFunctions.GameFunctions( diff --git a/HellionChat/Themes/ThemeRegistry.cs b/HellionChat/Themes/ThemeRegistry.cs index 4649bec..c0e70b4 100644 --- a/HellionChat/Themes/ThemeRegistry.cs +++ b/HellionChat/Themes/ThemeRegistry.cs @@ -1,9 +1,12 @@ using HellionChat.Themes.Builtin; +using Microsoft.Extensions.Logging; namespace HellionChat.Themes; public sealed class ThemeRegistry { + private readonly ILogger? _logger; + public const string DefaultSlug = HellionArctic.Slug; // 1Hz throttle for the v1.4.8 B2 auto-refresh-on-active path. The @@ -29,8 +32,9 @@ public sealed class ThemeRegistry private long _lastActiveStampCheckMs = -ActiveStampPollIntervalMs; private DateTime _lastActiveStamp = DateTime.MinValue; - public ThemeRegistry(string? customThemesDir = null) + public ThemeRegistry(string? customThemesDir = null, ILogger? logger = null) { + _logger = logger; // Insertion order drives the Theme-Picker grid layout (3 columns). // Row 1: blue family. Row 2: purple to magenta family. // Row 3: green / warm / classic. Row 4: Synthwave Sunset as a @@ -206,7 +210,7 @@ public sealed class ThemeRegistry catch (Exception ex) when (IsRecoverableFileLock(ex)) { // Editor mid-save: keep last known good, retry on next refresh. - Plugin.LogProxy.Debug( + _logger?.LogDebug( $"Custom theme {Path.GetFileName(path)} is locked, keeping last known good" ); if (cached.Theme is not null) diff --git a/HellionChat/Ui/ChatLogWindow.cs b/HellionChat/Ui/ChatLogWindow.cs index 421fed4..7800315 100644 --- a/HellionChat/Ui/ChatLogWindow.cs +++ b/HellionChat/Ui/ChatLogWindow.cs @@ -124,8 +124,10 @@ public sealed class ChatLogWindow : Window DisableWindowSounds = true; // AllowBackgroundBlur is set centrally in Plugin.Setup after AddWindow. - PayloadHandler = new PayloadHandler(this); - HandlerLender = new Lender(() => new PayloadHandler(this)); + PayloadHandler = new PayloadHandler(this, _loggerFactory.CreateLogger()); + HandlerLender = new Lender(() => + new PayloadHandler(this, _loggerFactory.CreateLogger()) + ); SetUpTextCommandChannels(); SetUpAllCommands();