From 63cad62c89211a60e7895c3124996e6484e62c98 Mon Sep 17 00:00:00 2001 From: Jon Kazama Date: Wed, 13 May 2026 08:22:12 +0200 Subject: [PATCH] refactor(ui): route logging through IPluginLogProxy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit F12.2 step 5a — UI cluster (~40 sites in 6 files): ChatLogWindow, DbViewer, Popout, SettingsTabs/{DataManagement, FontsAndColours, ThemeAndLayout}. Plugin.Log.X(...) → Plugin.LogProxy.X(...). No behaviour change; the proxy delegates 1:1 to the original IPluginLog. --- HellionChat/Ui/ChatLogWindow.cs | 28 +++++++-------- HellionChat/Ui/DbViewer.cs | 4 +-- HellionChat/Ui/Popout.cs | 14 ++++---- HellionChat/Ui/SettingsTabs/DataManagement.cs | 34 +++++++++++-------- .../Ui/SettingsTabs/FontsAndColours.cs | 2 +- HellionChat/Ui/SettingsTabs/ThemeAndLayout.cs | 2 +- 6 files changed, 44 insertions(+), 40 deletions(-) diff --git a/HellionChat/Ui/ChatLogWindow.cs b/HellionChat/Ui/ChatLogWindow.cs index 0f43eda..fb90cc5 100644 --- a/HellionChat/Ui/ChatLogWindow.cs +++ b/HellionChat/Ui/ChatLogWindow.cs @@ -277,7 +277,7 @@ public sealed class ChatLogWindow : Window || !GameFunctions.Chat.IsChannelOrExistingLinkshell(targetChannel.Value) ) { - Plugin.Log.Warning( + Plugin.LogProxy.Warning( $"Channel was set to an invalid value '{targetChannel}', ignoring" ); return; @@ -331,11 +331,11 @@ public sealed class ChatLogWindow : Window { case "hide": CurrentHideState = HideState.User; - Plugin.Log.Verbose("HideState: → User (chat hide command)"); + Plugin.LogProxy.Verbose("HideState: → User (chat hide command)"); break; case "show": CurrentHideState = HideState.None; - Plugin.Log.Verbose("HideState: → None (chat show command)"); + Plugin.LogProxy.Verbose("HideState: → None (chat show command)"); break; case "toggle": CurrentHideState = CurrentHideState switch @@ -345,7 +345,7 @@ public sealed class ChatLogWindow : Window HideState.None => HideState.User, _ => CurrentHideState, }; - Plugin.Log.Verbose($"HideState: → {CurrentHideState} (chat toggle command)"); + Plugin.LogProxy.Verbose($"HideState: → {CurrentHideState} (chat toggle command)"); break; } } @@ -469,14 +469,14 @@ public sealed class ChatLogWindow : Window if (Plugin.Config.HideInBattle && CurrentHideState == HideState.None && Plugin.InBattle) { CurrentHideState = HideState.Battle; - Plugin.Log.Verbose("HideState: None → Battle"); + Plugin.LogProxy.Verbose("HideState: None → Battle"); } // If the chat is hidden because of battle, we reset it here if (CurrentHideState is HideState.Battle && !Plugin.InBattle) { CurrentHideState = HideState.None; - Plugin.Log.Verbose("HideState: Battle → None"); + Plugin.LogProxy.Verbose("HideState: Battle → None"); } // if the chat has no hide state and in a cutscene, set the hide state to cutscene @@ -489,7 +489,7 @@ public sealed class ChatLogWindow : Window if (Plugin.Functions.Chat.CheckHideFlags()) { CurrentHideState = HideState.Cutscene; - Plugin.Log.Verbose("HideState: None → Cutscene"); + Plugin.LogProxy.Verbose("HideState: None → Cutscene"); } } @@ -500,7 +500,7 @@ public sealed class ChatLogWindow : Window && !Plugin.GposeActive ) { - Plugin.Log.Verbose($"HideState: {CurrentHideState} → None (cutscene/gpose ended)"); + Plugin.LogProxy.Verbose($"HideState: {CurrentHideState} → None (cutscene/gpose ended)"); CurrentHideState = HideState.None; } @@ -508,14 +508,14 @@ public sealed class ChatLogWindow : Window if (CurrentHideState == HideState.Cutscene && Activate) { CurrentHideState = HideState.CutsceneOverride; - Plugin.Log.Verbose("HideState: Cutscene → CutsceneOverride (user activate)"); + Plugin.LogProxy.Verbose("HideState: Cutscene → CutsceneOverride (user activate)"); } // if the user hid the chat and is now activating chat, reset the hide state if (CurrentHideState == HideState.User && Activate) { CurrentHideState = HideState.None; - Plugin.Log.Verbose("HideState: User → None (activate)"); + Plugin.LogProxy.Verbose("HideState: User → None (activate)"); } if ( @@ -633,7 +633,7 @@ public sealed class ChatLogWindow : Window } catch (Exception ex) { - Plugin.Log.Error(ex, "Error drawing Chat Log window"); + Plugin.LogProxy.Error(ex, "Error drawing Chat Log window"); if (!NotifiedDrawFailure) { Plugin.Notification.AddNotification( @@ -1608,7 +1608,7 @@ public sealed class ChatLogWindow : Window } catch (Exception ex) { - Plugin.Log.Warning(ex, "Error drawing chat log"); + Plugin.LogProxy.Warning(ex, "Error drawing chat log"); } } @@ -2059,7 +2059,7 @@ public sealed class ChatLogWindow : Window { Plugin.Config.SeenPopOutHeaderHint = true; Plugin.SaveConfig(); - Plugin.Log.Debug("v0.6.1 pop-out header hint dismissed"); + Plugin.LogProxy.Debug("v0.6.1 pop-out header hint dismissed"); if (openSettings) Plugin.SettingsWindow.Toggle(); } @@ -2672,7 +2672,7 @@ public sealed class ChatLogWindow : Window var viewport = ImGui.GetMainViewport(); var safePos = viewport.WorkPos + SafeDefaultOffset; Position = safePos; - Plugin.Log.Info( + Plugin.LogProxy.Info( $"[Window-Recovery] {source}: snapping main window from {LastWindowPos} (size {LastWindowSize}) to {safePos}." ); diff --git a/HellionChat/Ui/DbViewer.cs b/HellionChat/Ui/DbViewer.cs index 58b2c3c..1326a29 100644 --- a/HellionChat/Ui/DbViewer.cs +++ b/HellionChat/Ui/DbViewer.cs @@ -307,7 +307,7 @@ public class DbViewer : Window } catch (Exception ex) { - Plugin.Log.Error(ex, "Failed reading messages from database"); + Plugin.LogProxy.Error(ex, "Failed reading messages from database"); } finally { @@ -570,7 +570,7 @@ public class DbViewer : Window } catch (Exception ex) { - Plugin.Log.Error(ex, "Failed creating txt backup"); + Plugin.LogProxy.Error(ex, "Failed creating txt backup"); Notification.Content = "Error ..."; Notification.Type = NotificationType.Error; diff --git a/HellionChat/Ui/Popout.cs b/HellionChat/Ui/Popout.cs index fbbe483..3b6ddd6 100644 --- a/HellionChat/Ui/Popout.cs +++ b/HellionChat/Ui/Popout.cs @@ -175,7 +175,7 @@ internal class Popout : Window { Plugin.Config.SeenPopOutInputHint = true; ChatLogWindow.Plugin.SaveConfig(); - Plugin.Log.Debug("Pop-Out input hint dismissed"); + Plugin.LogProxy.Debug("Pop-Out input hint dismissed"); if (openSettings) ChatLogWindow.Plugin.SettingsWindow.Toggle(); } @@ -214,13 +214,13 @@ internal class Popout : Window if (Tab.HideInBattle && CurrentHideState == HideState.None && Plugin.InBattle) { CurrentHideState = HideState.Battle; - Plugin.Log.Verbose($"Popout HideState [{Tab.Name}]: None -> Battle"); + Plugin.LogProxy.Verbose($"Popout HideState [{Tab.Name}]: None -> Battle"); } if (CurrentHideState is HideState.Battle && !Plugin.InBattle) { CurrentHideState = HideState.None; - Plugin.Log.Verbose($"Popout HideState [{Tab.Name}]: Battle -> None"); + Plugin.LogProxy.Verbose($"Popout HideState [{Tab.Name}]: Battle -> None"); } if ( @@ -232,7 +232,7 @@ internal class Popout : Window if (ChatLogWindow.Plugin.Functions.Chat.CheckHideFlags()) { CurrentHideState = HideState.Cutscene; - Plugin.Log.Verbose($"Popout HideState [{Tab.Name}]: None -> Cutscene"); + Plugin.LogProxy.Verbose($"Popout HideState [{Tab.Name}]: None -> Cutscene"); } } @@ -242,7 +242,7 @@ internal class Popout : Window && !Plugin.GposeActive ) { - Plugin.Log.Verbose( + Plugin.LogProxy.Verbose( $"Popout HideState [{Tab.Name}]: {CurrentHideState} -> None (cutscene/gpose ended)" ); CurrentHideState = HideState.None; @@ -251,7 +251,7 @@ internal class Popout : Window if (CurrentHideState == HideState.Cutscene && ChatLogWindow.Activate) { CurrentHideState = HideState.CutsceneOverride; - Plugin.Log.Verbose( + Plugin.LogProxy.Verbose( $"Popout HideState [{Tab.Name}]: Cutscene -> CutsceneOverride (user activate)" ); } @@ -259,7 +259,7 @@ internal class Popout : Window if (CurrentHideState == HideState.User && ChatLogWindow.Activate) { CurrentHideState = HideState.None; - Plugin.Log.Verbose($"Popout HideState [{Tab.Name}]: User -> None (activate)"); + Plugin.LogProxy.Verbose($"Popout HideState [{Tab.Name}]: User -> None (activate)"); } return CurrentHideState is HideState.Cutscene or HideState.User or HideState.Battle diff --git a/HellionChat/Ui/SettingsTabs/DataManagement.cs b/HellionChat/Ui/SettingsTabs/DataManagement.cs index b63fe4b..bdcaef1 100644 --- a/HellionChat/Ui/SettingsTabs/DataManagement.cs +++ b/HellionChat/Ui/SettingsTabs/DataManagement.cs @@ -229,7 +229,7 @@ internal sealed class DataManagement : ISettingsTab } catch (Exception e) { - Plugin.Log.Error(e, "Unable to delete old database"); + Plugin.LogProxy.Error(e, "Unable to delete old database"); WrapperUtil.AddNotification( Language.Options_Database_Old_Delete_Error, NotificationType.Error @@ -391,7 +391,9 @@ internal sealed class DataManagement : ISettingsTab Plugin.Config.RetentionLastRunAt = DateTimeOffset.UtcNow; Plugin.SaveConfig(); - Plugin.Log.Information($"Manual retention run deleted {deleted} expired messages."); + Plugin.LogProxy.Information( + $"Manual retention run deleted {deleted} expired messages." + ); if (deleted > 0) { @@ -405,7 +407,7 @@ internal sealed class DataManagement : ISettingsTab .Wait(TimeSpan.FromSeconds(5)) ) { - Plugin.Log.Warning( + Plugin.LogProxy.Warning( "Retention sweep: framework refresh timed out after 5s." ); } @@ -418,7 +420,7 @@ internal sealed class DataManagement : ISettingsTab } catch (Exception e) { - Plugin.Log.Error(e, "Manual retention run failed"); + Plugin.LogProxy.Error(e, "Manual retention run failed"); WrapperUtil.AddNotification(HellionStrings.Retention_Error, NotificationType.Error); } finally @@ -566,7 +568,7 @@ internal sealed class DataManagement : ISettingsTab } catch (Exception e) { - Plugin.Log.Error(e, "Failed to compute cleanup preview"); + Plugin.LogProxy.Error(e, "Failed to compute cleanup preview"); WrapperUtil.AddNotification( HellionStrings.Cleanup_PreviewError, NotificationType.Error @@ -587,7 +589,7 @@ internal sealed class DataManagement : ISettingsTab try { var deleted = Plugin.MessageManager.Store.CleanupRetainOnly(allowed); - Plugin.Log.Information($"Privacy cleanup: deleted {deleted} messages"); + Plugin.LogProxy.Information($"Privacy cleanup: deleted {deleted} messages"); if ( !Plugin @@ -599,7 +601,9 @@ internal sealed class DataManagement : ISettingsTab .Wait(TimeSpan.FromSeconds(5)) ) { - Plugin.Log.Warning("Privacy cleanup: framework refresh timed out after 5s."); + Plugin.LogProxy.Warning( + "Privacy cleanup: framework refresh timed out after 5s." + ); } WrapperUtil.AddNotification( @@ -609,7 +613,7 @@ internal sealed class DataManagement : ISettingsTab } catch (Exception e) { - Plugin.Log.Error(e, "Privacy cleanup failed"); + Plugin.LogProxy.Error(e, "Privacy cleanup failed"); WrapperUtil.AddNotification(HellionStrings.Cleanup_Error, NotificationType.Error); } finally @@ -769,7 +773,7 @@ internal sealed class DataManagement : ISettingsTab } catch (Exception e) { - Plugin.Log.Error(e, "Export failed"); + Plugin.LogProxy.Error(e, "Export failed"); WrapperUtil.AddNotification(HellionStrings.Export_Error, NotificationType.Error); } finally @@ -849,7 +853,7 @@ internal sealed class DataManagement : ISettingsTab ) ) { - Plugin.Log.Warning("Clearing messages from database"); + Plugin.LogProxy.Warning("Clearing messages from database"); Plugin.MessageManager.Store.ClearMessages(); Plugin.MessageManager.ClearAllTabs(); @@ -907,7 +911,7 @@ internal sealed class DataManagement : ISettingsTab private void InsertMessages(int count) { - Plugin.Log.Info($"Inserting {count} messages due to user request"); + Plugin.LogProxy.Info($"Inserting {count} messages due to user request"); var stopwatch = Stopwatch.StartNew(); var playerName = Plugin.PlayerState.CharacterName; @@ -952,7 +956,7 @@ internal sealed class DataManagement : ISettingsTab var elapsedTicks = stopwatch.ElapsedTicks; stopwatch.Stop(); - Plugin.Log.Info( + Plugin.LogProxy.Info( $"Crafted {count} messages in {elapsedTicks} ticks ({elapsedTicks / TimeSpan.TicksPerMillisecond}ms)" ); @@ -962,7 +966,7 @@ internal sealed class DataManagement : ISettingsTab elapsedTicks = stopwatch.ElapsedTicks; stopwatch.Stop(); - Plugin.Log.Info( + Plugin.LogProxy.Info( $"Upserted {count} messages in {elapsedTicks} ticks ({elapsedTicks / TimeSpan.TicksPerMillisecond}ms)" ); @@ -973,7 +977,7 @@ internal sealed class DataManagement : ISettingsTab Plugin.MessageManager.ClearAllTabs(); elapsedTicks = stopwatch.ElapsedTicks; stopwatch.Stop(); - Plugin.Log.Info( + Plugin.LogProxy.Info( $"Cleared {Plugin.Config.Tabs.Count} tabs in {elapsedTicks} ticks ({elapsedTicks / TimeSpan.TicksPerMillisecond}ms)" ); }) @@ -986,7 +990,7 @@ internal sealed class DataManagement : ISettingsTab Plugin.MessageManager.FilterAllTabs(); elapsedTicks = stopwatch.ElapsedTicks; stopwatch.Stop(); - Plugin.Log.Info( + Plugin.LogProxy.Info( $"Fetched and filtered all tabs in {elapsedTicks} ticks ({elapsedTicks / TimeSpan.TicksPerMillisecond}ms)" ); }) diff --git a/HellionChat/Ui/SettingsTabs/FontsAndColours.cs b/HellionChat/Ui/SettingsTabs/FontsAndColours.cs index 759f1f7..7276549 100644 --- a/HellionChat/Ui/SettingsTabs/FontsAndColours.cs +++ b/HellionChat/Ui/SettingsTabs/FontsAndColours.cs @@ -312,6 +312,6 @@ internal sealed class FontsAndColours : ISettingsTab } Plugin.SaveConfig(); GlobalParametersCache.Refresh(); - Plugin.Log.Debug($"Applied chat colour preset: {preset.DisplayName}"); + Plugin.LogProxy.Debug($"Applied chat colour preset: {preset.DisplayName}"); } } diff --git a/HellionChat/Ui/SettingsTabs/ThemeAndLayout.cs b/HellionChat/Ui/SettingsTabs/ThemeAndLayout.cs index d87275d..890b76f 100644 --- a/HellionChat/Ui/SettingsTabs/ThemeAndLayout.cs +++ b/HellionChat/Ui/SettingsTabs/ThemeAndLayout.cs @@ -90,7 +90,7 @@ internal sealed class ThemeAndLayout : ISettingsTab var path = Path.Combine(dir, fileName); var json = ThemeJsonWriter.Serialize(active); File.WriteAllText(path, json); - Plugin.Log.Information($"Exported active theme '{active.Slug}' to {path}"); + Plugin.LogProxy.Information($"Exported active theme '{active.Slug}' to {path}"); } } }