refactor(di): migrate UI Window-Layer to ILogger<T> (DI-4 Slice C)
Six UI files shift from Plugin.LogProxy to ILogger<T> via constructor injection. Container singletons (each takes a typed ILogger plus, where it owns nested allocations, an ILoggerFactory to spawn child loggers): - Ui/ChatLogWindow (15 sites, plus an ILoggerFactory for the Popout new-call at Ui/ChatLogWindow.cs:2417) - Ui/Settings (SettingsWindow): no own sites, but takes an ILoggerFactory so it can hand typed loggers to its three migrated settings tabs (General, the other six tabs stay unchanged) - Ui/DbViewer (3 sites) Nested instances allocated by parent containers: - Ui/Popout (7 sites, ILogger<Popout> as the new 4th ctor arg passed from ChatLogWindow) - Ui/SettingsTabs/ThemeAndLayout (1 site) - Ui/SettingsTabs/FontsAndColours (1 site) - Ui/SettingsTabs/DataManagement (15 sites) PluginHostFactory factory lambdas updated for ChatLogWindow, SettingsWindow and DbViewer to resolve the new logger args.
This commit is contained in:
@@ -4,6 +4,7 @@ using Dalamud.Interface.Utility.Raii;
|
||||
using HellionChat.Resources;
|
||||
using HellionChat.Themes;
|
||||
using HellionChat.Util;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace HellionChat.Ui.SettingsTabs;
|
||||
|
||||
@@ -11,16 +12,18 @@ internal sealed class ThemeAndLayout : ISettingsTab
|
||||
{
|
||||
private Plugin Plugin { get; }
|
||||
private Configuration Mutable { get; }
|
||||
private readonly ILogger<ThemeAndLayout> _logger;
|
||||
|
||||
private string? _applyDismissedFor;
|
||||
|
||||
public string Name =>
|
||||
HellionStrings.Settings_Card_ThemeAndLayout_Title + "###tabs-themeandlayout";
|
||||
|
||||
internal ThemeAndLayout(Plugin plugin, Configuration mutable)
|
||||
internal ThemeAndLayout(Plugin plugin, Configuration mutable, ILogger<ThemeAndLayout> logger)
|
||||
{
|
||||
Plugin = plugin;
|
||||
Mutable = mutable;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void Draw(bool changed)
|
||||
@@ -90,7 +93,7 @@ internal sealed class ThemeAndLayout : ISettingsTab
|
||||
var path = Path.Combine(dir, fileName);
|
||||
var json = ThemeJsonWriter.Serialize(active);
|
||||
File.WriteAllText(path, json);
|
||||
Plugin.LogProxy.Information($"Exported active theme '{active.Slug}' to {path}");
|
||||
_logger.LogInformation($"Exported active theme '{active.Slug}' to {path}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user