From 4f8de2e20592f9d3b0c87b38bcfb5626e62475ec Mon Sep 17 00:00:00 2001 From: Kaz Wolfe Date: Fri, 22 Sep 2023 17:01:10 -0700 Subject: [PATCH] Obsolete (static) PluginLog for future removal - Mark PluginLog as obsoleted and pending removal, encouraging users to switch to IPluginLog. - Remove internal references to PluginLog. --- Dalamud.CorePlugin/PluginImpl.cs | 11 ++++++----- Dalamud/Logging/PluginLog.cs | 8 ++++++-- Dalamud/Utility/Signatures/SignatureHelper.cs | 9 +++------ 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Dalamud.CorePlugin/PluginImpl.cs b/Dalamud.CorePlugin/PluginImpl.cs index 2f76a1087..e2b373d42 100644 --- a/Dalamud.CorePlugin/PluginImpl.cs +++ b/Dalamud.CorePlugin/PluginImpl.cs @@ -1,10 +1,8 @@ using System; using System.IO; - using Dalamud.Configuration.Internal; using Dalamud.Game.Command; using Dalamud.Interface.Windowing; -using Dalamud.Logging; using Dalamud.Plugin; using Dalamud.Plugin.Services; using Dalamud.Utility; @@ -52,6 +50,8 @@ namespace Dalamud.CorePlugin private readonly WindowSystem windowSystem = new("Dalamud.CorePlugin"); private Localization localization; + private IPluginLog pluginLog; + /// /// Initializes a new instance of the class. /// @@ -63,6 +63,7 @@ namespace Dalamud.CorePlugin { // this.InitLoc(); this.Interface = pluginInterface; + this.pluginLog = log; this.windowSystem.AddWindow(new PluginWindow()); @@ -76,7 +77,7 @@ namespace Dalamud.CorePlugin } catch (Exception ex) { - PluginLog.Error(ex, "kaboom"); + log.Error(ex, "kaboom"); } } @@ -130,13 +131,13 @@ namespace Dalamud.CorePlugin } catch (Exception ex) { - PluginLog.Error(ex, "Boom"); + this.pluginLog.Error(ex, "Boom"); } } private void OnCommand(string command, string args) { - PluginLog.Information("Command called!"); + this.pluginLog.Information("Command called!"); // this.window.IsOpen = true; } diff --git a/Dalamud/Logging/PluginLog.cs b/Dalamud/Logging/PluginLog.cs index 3ac98f15a..c3fe0c808 100644 --- a/Dalamud/Logging/PluginLog.cs +++ b/Dalamud/Logging/PluginLog.cs @@ -1,6 +1,5 @@ -using System; using System.Reflection; - +using Dalamud.Plugin.Services; using Serilog; using Serilog.Events; @@ -9,6 +8,11 @@ namespace Dalamud.Logging; /// /// Class offering various static methods to allow for logging in plugins. /// +/// +/// PluginLog has been obsoleted and replaced by the service. Developers are encouraged to +/// move over as soon as reasonably possible for performance reasons. +/// +[Obsolete("Static PluginLog will be removed in API 10. Developers should use IPluginLog.")] public static class PluginLog { #region "Log" prefixed Serilog style methods diff --git a/Dalamud/Utility/Signatures/SignatureHelper.cs b/Dalamud/Utility/Signatures/SignatureHelper.cs index bd99b8515..20b45e7fb 100755 --- a/Dalamud/Utility/Signatures/SignatureHelper.cs +++ b/Dalamud/Utility/Signatures/SignatureHelper.cs @@ -1,11 +1,8 @@ -using System; -using System.Linq; +using System.Linq; using System.Reflection; using System.Runtime.InteropServices; - using Dalamud.Game; using Dalamud.Hooking; -using Dalamud.Logging; using Dalamud.Utility.Signatures.Wrappers; using Serilog; @@ -23,7 +20,7 @@ public static class SignatureHelper /// . /// /// The object to initialise. - /// If warnings should be logged using . + /// If warnings should be logged. public static void Initialise(object self, bool log = true) { var scanner = Service.Get(); @@ -61,7 +58,7 @@ public static class SignatureHelper : message; if (fallible) { - PluginLog.Warning(errorMsg); + Log.Warning(errorMsg); } else {