refactor(ui): route logging through IPluginLogProxy

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.
This commit is contained in:
2026-05-13 08:22:12 +02:00
parent dca5de4085
commit 63cad62c89
6 changed files with 44 additions and 40 deletions
+14 -14
View File
@@ -277,7 +277,7 @@ public sealed class ChatLogWindow : Window
|| !GameFunctions.Chat.IsChannelOrExistingLinkshell(targetChannel.Value) || !GameFunctions.Chat.IsChannelOrExistingLinkshell(targetChannel.Value)
) )
{ {
Plugin.Log.Warning( Plugin.LogProxy.Warning(
$"Channel was set to an invalid value '{targetChannel}', ignoring" $"Channel was set to an invalid value '{targetChannel}', ignoring"
); );
return; return;
@@ -331,11 +331,11 @@ public sealed class ChatLogWindow : Window
{ {
case "hide": case "hide":
CurrentHideState = HideState.User; CurrentHideState = HideState.User;
Plugin.Log.Verbose("HideState: → User (chat hide command)"); Plugin.LogProxy.Verbose("HideState: → User (chat hide command)");
break; break;
case "show": case "show":
CurrentHideState = HideState.None; CurrentHideState = HideState.None;
Plugin.Log.Verbose("HideState: → None (chat show command)"); Plugin.LogProxy.Verbose("HideState: → None (chat show command)");
break; break;
case "toggle": case "toggle":
CurrentHideState = CurrentHideState switch CurrentHideState = CurrentHideState switch
@@ -345,7 +345,7 @@ public sealed class ChatLogWindow : Window
HideState.None => HideState.User, HideState.None => HideState.User,
_ => CurrentHideState, _ => CurrentHideState,
}; };
Plugin.Log.Verbose($"HideState: → {CurrentHideState} (chat toggle command)"); Plugin.LogProxy.Verbose($"HideState: → {CurrentHideState} (chat toggle command)");
break; break;
} }
} }
@@ -469,14 +469,14 @@ public sealed class ChatLogWindow : Window
if (Plugin.Config.HideInBattle && CurrentHideState == HideState.None && Plugin.InBattle) if (Plugin.Config.HideInBattle && CurrentHideState == HideState.None && Plugin.InBattle)
{ {
CurrentHideState = HideState.Battle; 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 the chat is hidden because of battle, we reset it here
if (CurrentHideState is HideState.Battle && !Plugin.InBattle) if (CurrentHideState is HideState.Battle && !Plugin.InBattle)
{ {
CurrentHideState = HideState.None; 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 // 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()) if (Plugin.Functions.Chat.CheckHideFlags())
{ {
CurrentHideState = HideState.Cutscene; 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.GposeActive
) )
{ {
Plugin.Log.Verbose($"HideState: {CurrentHideState} → None (cutscene/gpose ended)"); Plugin.LogProxy.Verbose($"HideState: {CurrentHideState} → None (cutscene/gpose ended)");
CurrentHideState = HideState.None; CurrentHideState = HideState.None;
} }
@@ -508,14 +508,14 @@ public sealed class ChatLogWindow : Window
if (CurrentHideState == HideState.Cutscene && Activate) if (CurrentHideState == HideState.Cutscene && Activate)
{ {
CurrentHideState = HideState.CutsceneOverride; 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 the user hid the chat and is now activating chat, reset the hide state
if (CurrentHideState == HideState.User && Activate) if (CurrentHideState == HideState.User && Activate)
{ {
CurrentHideState = HideState.None; CurrentHideState = HideState.None;
Plugin.Log.Verbose("HideState: User → None (activate)"); Plugin.LogProxy.Verbose("HideState: User → None (activate)");
} }
if ( if (
@@ -633,7 +633,7 @@ public sealed class ChatLogWindow : Window
} }
catch (Exception ex) catch (Exception ex)
{ {
Plugin.Log.Error(ex, "Error drawing Chat Log window"); Plugin.LogProxy.Error(ex, "Error drawing Chat Log window");
if (!NotifiedDrawFailure) if (!NotifiedDrawFailure)
{ {
Plugin.Notification.AddNotification( Plugin.Notification.AddNotification(
@@ -1608,7 +1608,7 @@ public sealed class ChatLogWindow : Window
} }
catch (Exception ex) 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.Config.SeenPopOutHeaderHint = true;
Plugin.SaveConfig(); 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) if (openSettings)
Plugin.SettingsWindow.Toggle(); Plugin.SettingsWindow.Toggle();
} }
@@ -2672,7 +2672,7 @@ public sealed class ChatLogWindow : Window
var viewport = ImGui.GetMainViewport(); var viewport = ImGui.GetMainViewport();
var safePos = viewport.WorkPos + SafeDefaultOffset; var safePos = viewport.WorkPos + SafeDefaultOffset;
Position = safePos; Position = safePos;
Plugin.Log.Info( Plugin.LogProxy.Info(
$"[Window-Recovery] {source}: snapping main window from {LastWindowPos} (size {LastWindowSize}) to {safePos}." $"[Window-Recovery] {source}: snapping main window from {LastWindowPos} (size {LastWindowSize}) to {safePos}."
); );
+2 -2
View File
@@ -307,7 +307,7 @@ public class DbViewer : Window
} }
catch (Exception ex) catch (Exception ex)
{ {
Plugin.Log.Error(ex, "Failed reading messages from database"); Plugin.LogProxy.Error(ex, "Failed reading messages from database");
} }
finally finally
{ {
@@ -570,7 +570,7 @@ public class DbViewer : Window
} }
catch (Exception ex) catch (Exception ex)
{ {
Plugin.Log.Error(ex, "Failed creating txt backup"); Plugin.LogProxy.Error(ex, "Failed creating txt backup");
Notification.Content = "Error ..."; Notification.Content = "Error ...";
Notification.Type = NotificationType.Error; Notification.Type = NotificationType.Error;
+7 -7
View File
@@ -175,7 +175,7 @@ internal class Popout : Window
{ {
Plugin.Config.SeenPopOutInputHint = true; Plugin.Config.SeenPopOutInputHint = true;
ChatLogWindow.Plugin.SaveConfig(); ChatLogWindow.Plugin.SaveConfig();
Plugin.Log.Debug("Pop-Out input hint dismissed"); Plugin.LogProxy.Debug("Pop-Out input hint dismissed");
if (openSettings) if (openSettings)
ChatLogWindow.Plugin.SettingsWindow.Toggle(); ChatLogWindow.Plugin.SettingsWindow.Toggle();
} }
@@ -214,13 +214,13 @@ internal class Popout : Window
if (Tab.HideInBattle && CurrentHideState == HideState.None && Plugin.InBattle) if (Tab.HideInBattle && CurrentHideState == HideState.None && Plugin.InBattle)
{ {
CurrentHideState = HideState.Battle; 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) if (CurrentHideState is HideState.Battle && !Plugin.InBattle)
{ {
CurrentHideState = HideState.None; CurrentHideState = HideState.None;
Plugin.Log.Verbose($"Popout HideState [{Tab.Name}]: Battle -> None"); Plugin.LogProxy.Verbose($"Popout HideState [{Tab.Name}]: Battle -> None");
} }
if ( if (
@@ -232,7 +232,7 @@ internal class Popout : Window
if (ChatLogWindow.Plugin.Functions.Chat.CheckHideFlags()) if (ChatLogWindow.Plugin.Functions.Chat.CheckHideFlags())
{ {
CurrentHideState = HideState.Cutscene; 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.GposeActive
) )
{ {
Plugin.Log.Verbose( Plugin.LogProxy.Verbose(
$"Popout HideState [{Tab.Name}]: {CurrentHideState} -> None (cutscene/gpose ended)" $"Popout HideState [{Tab.Name}]: {CurrentHideState} -> None (cutscene/gpose ended)"
); );
CurrentHideState = HideState.None; CurrentHideState = HideState.None;
@@ -251,7 +251,7 @@ internal class Popout : Window
if (CurrentHideState == HideState.Cutscene && ChatLogWindow.Activate) if (CurrentHideState == HideState.Cutscene && ChatLogWindow.Activate)
{ {
CurrentHideState = HideState.CutsceneOverride; CurrentHideState = HideState.CutsceneOverride;
Plugin.Log.Verbose( Plugin.LogProxy.Verbose(
$"Popout HideState [{Tab.Name}]: Cutscene -> CutsceneOverride (user activate)" $"Popout HideState [{Tab.Name}]: Cutscene -> CutsceneOverride (user activate)"
); );
} }
@@ -259,7 +259,7 @@ internal class Popout : Window
if (CurrentHideState == HideState.User && ChatLogWindow.Activate) if (CurrentHideState == HideState.User && ChatLogWindow.Activate)
{ {
CurrentHideState = HideState.None; 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 return CurrentHideState is HideState.Cutscene or HideState.User or HideState.Battle
+19 -15
View File
@@ -229,7 +229,7 @@ internal sealed class DataManagement : ISettingsTab
} }
catch (Exception e) catch (Exception e)
{ {
Plugin.Log.Error(e, "Unable to delete old database"); Plugin.LogProxy.Error(e, "Unable to delete old database");
WrapperUtil.AddNotification( WrapperUtil.AddNotification(
Language.Options_Database_Old_Delete_Error, Language.Options_Database_Old_Delete_Error,
NotificationType.Error NotificationType.Error
@@ -391,7 +391,9 @@ internal sealed class DataManagement : ISettingsTab
Plugin.Config.RetentionLastRunAt = DateTimeOffset.UtcNow; Plugin.Config.RetentionLastRunAt = DateTimeOffset.UtcNow;
Plugin.SaveConfig(); 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) if (deleted > 0)
{ {
@@ -405,7 +407,7 @@ internal sealed class DataManagement : ISettingsTab
.Wait(TimeSpan.FromSeconds(5)) .Wait(TimeSpan.FromSeconds(5))
) )
{ {
Plugin.Log.Warning( Plugin.LogProxy.Warning(
"Retention sweep: framework refresh timed out after 5s." "Retention sweep: framework refresh timed out after 5s."
); );
} }
@@ -418,7 +420,7 @@ internal sealed class DataManagement : ISettingsTab
} }
catch (Exception e) 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); WrapperUtil.AddNotification(HellionStrings.Retention_Error, NotificationType.Error);
} }
finally finally
@@ -566,7 +568,7 @@ internal sealed class DataManagement : ISettingsTab
} }
catch (Exception e) catch (Exception e)
{ {
Plugin.Log.Error(e, "Failed to compute cleanup preview"); Plugin.LogProxy.Error(e, "Failed to compute cleanup preview");
WrapperUtil.AddNotification( WrapperUtil.AddNotification(
HellionStrings.Cleanup_PreviewError, HellionStrings.Cleanup_PreviewError,
NotificationType.Error NotificationType.Error
@@ -587,7 +589,7 @@ internal sealed class DataManagement : ISettingsTab
try try
{ {
var deleted = Plugin.MessageManager.Store.CleanupRetainOnly(allowed); var deleted = Plugin.MessageManager.Store.CleanupRetainOnly(allowed);
Plugin.Log.Information($"Privacy cleanup: deleted {deleted} messages"); Plugin.LogProxy.Information($"Privacy cleanup: deleted {deleted} messages");
if ( if (
!Plugin !Plugin
@@ -599,7 +601,9 @@ internal sealed class DataManagement : ISettingsTab
.Wait(TimeSpan.FromSeconds(5)) .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( WrapperUtil.AddNotification(
@@ -609,7 +613,7 @@ internal sealed class DataManagement : ISettingsTab
} }
catch (Exception e) catch (Exception e)
{ {
Plugin.Log.Error(e, "Privacy cleanup failed"); Plugin.LogProxy.Error(e, "Privacy cleanup failed");
WrapperUtil.AddNotification(HellionStrings.Cleanup_Error, NotificationType.Error); WrapperUtil.AddNotification(HellionStrings.Cleanup_Error, NotificationType.Error);
} }
finally finally
@@ -769,7 +773,7 @@ internal sealed class DataManagement : ISettingsTab
} }
catch (Exception e) catch (Exception e)
{ {
Plugin.Log.Error(e, "Export failed"); Plugin.LogProxy.Error(e, "Export failed");
WrapperUtil.AddNotification(HellionStrings.Export_Error, NotificationType.Error); WrapperUtil.AddNotification(HellionStrings.Export_Error, NotificationType.Error);
} }
finally 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.Store.ClearMessages();
Plugin.MessageManager.ClearAllTabs(); Plugin.MessageManager.ClearAllTabs();
@@ -907,7 +911,7 @@ internal sealed class DataManagement : ISettingsTab
private void InsertMessages(int count) 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 stopwatch = Stopwatch.StartNew();
var playerName = Plugin.PlayerState.CharacterName; var playerName = Plugin.PlayerState.CharacterName;
@@ -952,7 +956,7 @@ internal sealed class DataManagement : ISettingsTab
var elapsedTicks = stopwatch.ElapsedTicks; var elapsedTicks = stopwatch.ElapsedTicks;
stopwatch.Stop(); stopwatch.Stop();
Plugin.Log.Info( Plugin.LogProxy.Info(
$"Crafted {count} messages in {elapsedTicks} ticks ({elapsedTicks / TimeSpan.TicksPerMillisecond}ms)" $"Crafted {count} messages in {elapsedTicks} ticks ({elapsedTicks / TimeSpan.TicksPerMillisecond}ms)"
); );
@@ -962,7 +966,7 @@ internal sealed class DataManagement : ISettingsTab
elapsedTicks = stopwatch.ElapsedTicks; elapsedTicks = stopwatch.ElapsedTicks;
stopwatch.Stop(); stopwatch.Stop();
Plugin.Log.Info( Plugin.LogProxy.Info(
$"Upserted {count} messages in {elapsedTicks} ticks ({elapsedTicks / TimeSpan.TicksPerMillisecond}ms)" $"Upserted {count} messages in {elapsedTicks} ticks ({elapsedTicks / TimeSpan.TicksPerMillisecond}ms)"
); );
@@ -973,7 +977,7 @@ internal sealed class DataManagement : ISettingsTab
Plugin.MessageManager.ClearAllTabs(); Plugin.MessageManager.ClearAllTabs();
elapsedTicks = stopwatch.ElapsedTicks; elapsedTicks = stopwatch.ElapsedTicks;
stopwatch.Stop(); stopwatch.Stop();
Plugin.Log.Info( Plugin.LogProxy.Info(
$"Cleared {Plugin.Config.Tabs.Count} tabs in {elapsedTicks} ticks ({elapsedTicks / TimeSpan.TicksPerMillisecond}ms)" $"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(); Plugin.MessageManager.FilterAllTabs();
elapsedTicks = stopwatch.ElapsedTicks; elapsedTicks = stopwatch.ElapsedTicks;
stopwatch.Stop(); stopwatch.Stop();
Plugin.Log.Info( Plugin.LogProxy.Info(
$"Fetched and filtered all tabs in {elapsedTicks} ticks ({elapsedTicks / TimeSpan.TicksPerMillisecond}ms)" $"Fetched and filtered all tabs in {elapsedTicks} ticks ({elapsedTicks / TimeSpan.TicksPerMillisecond}ms)"
); );
}) })
@@ -312,6 +312,6 @@ internal sealed class FontsAndColours : ISettingsTab
} }
Plugin.SaveConfig(); Plugin.SaveConfig();
GlobalParametersCache.Refresh(); GlobalParametersCache.Refresh();
Plugin.Log.Debug($"Applied chat colour preset: {preset.DisplayName}"); Plugin.LogProxy.Debug($"Applied chat colour preset: {preset.DisplayName}");
} }
} }
@@ -90,7 +90,7 @@ internal sealed class ThemeAndLayout : ISettingsTab
var path = Path.Combine(dir, fileName); var path = Path.Combine(dir, fileName);
var json = ThemeJsonWriter.Serialize(active); var json = ThemeJsonWriter.Serialize(active);
File.WriteAllText(path, json); File.WriteAllText(path, json);
Plugin.Log.Information($"Exported active theme '{active.Slug}' to {path}"); Plugin.LogProxy.Information($"Exported active theme '{active.Slug}' to {path}");
} }
} }
} }