From 3b8ef2c8e8cf198e9a1ec1c521a3dc86887dbeaa Mon Sep 17 00:00:00 2001 From: Kaz Wolfe Date: Sat, 20 Apr 2024 10:57:59 -0700 Subject: [PATCH] chore: Remove static PluginLog - API 10 deprecation --- Dalamud/Logging/PluginLog.cs | 282 ------------------ Dalamud/Utility/Signatures/SignatureHelper.cs | 2 +- 2 files changed, 1 insertion(+), 283 deletions(-) delete mode 100644 Dalamud/Logging/PluginLog.cs diff --git a/Dalamud/Logging/PluginLog.cs b/Dalamud/Logging/PluginLog.cs deleted file mode 100644 index e3744c617..000000000 --- a/Dalamud/Logging/PluginLog.cs +++ /dev/null @@ -1,282 +0,0 @@ -using System.Reflection; - -using Dalamud.Plugin.Services; -using Dalamud.Utility; - -using Serilog; -using Serilog.Events; - -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.")] -[Api10ToDo(Api10ToDoAttribute.DeleteCompatBehavior)] -public static class PluginLog -{ - #region "Log" prefixed Serilog style methods - - /// - /// Log a templated message to the in-game debug log. - /// - /// The message template. - /// Values to log. - public static void Log(string messageTemplate, params object[] values) - => WriteLog(Assembly.GetCallingAssembly().GetName().Name, LogEventLevel.Information, messageTemplate, null, values); - - /// - /// Log a templated message to the in-game debug log. - /// - /// The exception that caused the error. - /// The message template. - /// Values to log. - public static void Log(Exception? exception, string messageTemplate, params object[] values) - => WriteLog(Assembly.GetCallingAssembly().GetName().Name, LogEventLevel.Information, messageTemplate, exception, values); - - /// - /// Log a templated verbose message to the in-game debug log. - /// - /// The message template. - /// Values to log. - public static void LogVerbose(string messageTemplate, params object[] values) - => WriteLog(Assembly.GetCallingAssembly().GetName().Name, LogEventLevel.Verbose, messageTemplate, null, values); - - /// - /// Log a templated verbose message to the in-game debug log. - /// - /// The exception that caused the error. - /// The message template. - /// Values to log. - public static void LogVerbose(Exception? exception, string messageTemplate, params object[] values) - => WriteLog(Assembly.GetCallingAssembly().GetName().Name, LogEventLevel.Verbose, messageTemplate, exception, values); - - /// - /// Log a templated debug message to the in-game debug log. - /// - /// The message template. - /// Values to log. - public static void LogDebug(string messageTemplate, params object[] values) - => WriteLog(Assembly.GetCallingAssembly().GetName().Name, LogEventLevel.Debug, messageTemplate, null, values); - - /// - /// Log a templated debug message to the in-game debug log. - /// - /// The exception that caused the error. - /// The message template. - /// Values to log. - public static void LogDebug(Exception? exception, string messageTemplate, params object[] values) - => WriteLog(Assembly.GetCallingAssembly().GetName().Name, LogEventLevel.Debug, messageTemplate, exception, values); - - /// - /// Log a templated information message to the in-game debug log. - /// - /// The message template. - /// Values to log. - public static void LogInformation(string messageTemplate, params object[] values) - => WriteLog(Assembly.GetCallingAssembly().GetName().Name, LogEventLevel.Information, messageTemplate, null, values); - - /// - /// Log a templated information message to the in-game debug log. - /// - /// The exception that caused the error. - /// The message template. - /// Values to log. - public static void LogInformation(Exception? exception, string messageTemplate, params object[] values) - => WriteLog(Assembly.GetCallingAssembly().GetName().Name, LogEventLevel.Information, messageTemplate, exception, values); - - /// - /// Log a templated warning message to the in-game debug log. - /// - /// The message template. - /// Values to log. - public static void LogWarning(string messageTemplate, params object[] values) - => WriteLog(Assembly.GetCallingAssembly().GetName().Name, LogEventLevel.Warning, messageTemplate, null, values); - - /// - /// Log a templated warning message to the in-game debug log. - /// - /// The exception that caused the error. - /// The message template. - /// Values to log. - public static void LogWarning(Exception? exception, string messageTemplate, params object[] values) - => WriteLog(Assembly.GetCallingAssembly().GetName().Name, LogEventLevel.Warning, messageTemplate, exception, values); - - /// - /// Log a templated error message to the in-game debug log. - /// - /// The message template. - /// Values to log. - public static void LogError(string messageTemplate, params object[] values) - => WriteLog(Assembly.GetCallingAssembly().GetName().Name, LogEventLevel.Error, messageTemplate, null, values); - - /// - /// Log a templated error message to the in-game debug log. - /// - /// The exception that caused the error. - /// The message template. - /// Values to log. - public static void LogError(Exception? exception, string messageTemplate, params object[] values) - => WriteLog(Assembly.GetCallingAssembly().GetName().Name, LogEventLevel.Error, messageTemplate, exception, values); - - /// - /// Log a templated fatal message to the in-game debug log. - /// - /// The message template. - /// Values to log. - public static void LogFatal(string messageTemplate, params object[] values) - => WriteLog(Assembly.GetCallingAssembly().GetName().Name, LogEventLevel.Fatal, messageTemplate, null, values); - - /// - /// Log a templated fatal message to the in-game debug log. - /// - /// The exception that caused the error. - /// The message template. - /// Values to log. - public static void LogFatal(Exception? exception, string messageTemplate, params object[] values) - => WriteLog(Assembly.GetCallingAssembly().GetName().Name, LogEventLevel.Fatal, messageTemplate, exception, values); - - #endregion - - #region Serilog style methods - - /// - /// Log a templated verbose message to the in-game debug log. - /// - /// The message template. - /// Values to log. - public static void Verbose(string messageTemplate, params object[] values) - => WriteLog(Assembly.GetCallingAssembly().GetName().Name, LogEventLevel.Verbose, messageTemplate, null, values); - - /// - /// Log a templated verbose message to the in-game debug log. - /// - /// The exception that caused the error. - /// The message template. - /// Values to log. - public static void Verbose(Exception? exception, string messageTemplate, params object[] values) - => WriteLog(Assembly.GetCallingAssembly().GetName().Name, LogEventLevel.Verbose, messageTemplate, exception, values); - - /// - /// Log a templated debug message to the in-game debug log. - /// - /// The message template. - /// Values to log. - public static void Debug(string messageTemplate, params object[] values) - => WriteLog(Assembly.GetCallingAssembly().GetName().Name, LogEventLevel.Debug, messageTemplate, null, values); - - /// - /// Log a templated debug message to the in-game debug log. - /// - /// The exception that caused the error. - /// The message template. - /// Values to log. - public static void Debug(Exception? exception, string messageTemplate, params object[] values) - => WriteLog(Assembly.GetCallingAssembly().GetName().Name, LogEventLevel.Debug, messageTemplate, exception, values); - - /// - /// Log a templated information message to the in-game debug log. - /// - /// The message template. - /// Values to log. - public static void Information(string messageTemplate, params object[] values) - => WriteLog(Assembly.GetCallingAssembly().GetName().Name, LogEventLevel.Information, messageTemplate, null, values); - - /// - /// Log a templated information message to the in-game debug log. - /// - /// The exception that caused the error. - /// The message template. - /// Values to log. - public static void Information(Exception? exception, string messageTemplate, params object[] values) - => WriteLog(Assembly.GetCallingAssembly().GetName().Name, LogEventLevel.Information, messageTemplate, exception, values); - - /// - /// Log a templated warning message to the in-game debug log. - /// - /// The message template. - /// Values to log. - public static void Warning(string messageTemplate, params object[] values) - => WriteLog(Assembly.GetCallingAssembly().GetName().Name, LogEventLevel.Warning, messageTemplate, null, values); - - /// - /// Log a templated warning message to the in-game debug log. - /// - /// The exception that caused the error. - /// The message template. - /// Values to log. - public static void Warning(Exception? exception, string messageTemplate, params object[] values) - => WriteLog(Assembly.GetCallingAssembly().GetName().Name, LogEventLevel.Warning, messageTemplate, exception, values); - - /// - /// Log a templated error message to the in-game debug log. - /// - /// The message template. - /// Values to log. - public static void Error(string messageTemplate, params object[] values) - => WriteLog(Assembly.GetCallingAssembly().GetName().Name, LogEventLevel.Error, messageTemplate, null, values); - - /// - /// Log a templated error message to the in-game debug log. - /// - /// The exception that caused the error. - /// The message template. - /// Values to log. - public static void Error(Exception? exception, string messageTemplate, params object[] values) - => WriteLog(Assembly.GetCallingAssembly().GetName().Name, LogEventLevel.Error, messageTemplate, exception, values); - - /// - /// Log a templated fatal message to the in-game debug log. - /// - /// The message template. - /// Values to log. - public static void Fatal(string messageTemplate, params object[] values) - => WriteLog(Assembly.GetCallingAssembly().GetName().Name, LogEventLevel.Fatal, messageTemplate, null, values); - - /// - /// Log a templated fatal message to the in-game debug log. - /// - /// The exception that caused the error. - /// The message template. - /// Values to log. - public static void Fatal(Exception? exception, string messageTemplate, params object[] values) - => WriteLog(Assembly.GetCallingAssembly().GetName().Name, LogEventLevel.Fatal, messageTemplate, exception, values); - - #endregion - - /// - /// Log a message to the in-game log, setting level at runtime. - /// - /// - /// This method is primarily meant for interoperability with other logging systems that may want to be forwarded to - /// the PluginLog. - /// - /// The log level for this message. - /// An exception (if any) to include in this log message. - /// The message template. - /// Values to log. - public static void LogRaw(LogEventLevel level, Exception? exception, string messageTemplate, params object[] values) - => WriteLog(Assembly.GetCallingAssembly().GetName().Name, level, messageTemplate, exception, values); - - private static ILogger GetPluginLogger(string? pluginName) - { - return Serilog.Log.ForContext("Dalamud.PluginName", pluginName ?? string.Empty); - } - - private static void WriteLog(string? pluginName, LogEventLevel level, string messageTemplate, Exception? exception = null, params object[] values) - { - var pluginLogger = GetPluginLogger(pluginName); - - // FIXME: Eventually, the `pluginName` tag should be removed from here and moved over to the actual log - // formatter. - pluginLogger.Write( - level, - exception: exception, - messageTemplate: $"[{pluginName}] {messageTemplate}", - values); - } -} diff --git a/Dalamud/Utility/Signatures/SignatureHelper.cs b/Dalamud/Utility/Signatures/SignatureHelper.cs index e34d8ef69..bd90a0d13 100755 --- a/Dalamud/Utility/Signatures/SignatureHelper.cs +++ b/Dalamud/Utility/Signatures/SignatureHelper.cs @@ -25,7 +25,7 @@ internal static class SignatureHelper /// . /// /// The object to initialize. - /// If warnings should be logged using . + /// If warnings should be logged. /// Collection of created IDalamudHooks. internal static IEnumerable Initialize(object self, bool log = true) {