From 3a688b9219deb479d07cc2ddf1735d9e428a1c0f Mon Sep 17 00:00:00 2001 From: goat Date: Fri, 14 Feb 2020 22:58:55 +0900 Subject: [PATCH] feat: add logging to DalamudPluginInterface, so plugins don't have to get Serilog --- Dalamud/Plugin/DalamudPluginInterface.cs | 34 ++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/Dalamud/Plugin/DalamudPluginInterface.cs b/Dalamud/Plugin/DalamudPluginInterface.cs index 8e1eaea4b..d6d603346 100644 --- a/Dalamud/Plugin/DalamudPluginInterface.cs +++ b/Dalamud/Plugin/DalamudPluginInterface.cs @@ -109,5 +109,39 @@ namespace Dalamud.Plugin return this.dalamud.Configuration.PluginConfigurations[this.pluginName] as IPluginConfiguration; } + + #region Logging + + /// + /// Log a templated message to the in-game debug log. + /// + /// The message template. + /// Values to log. + public void Log(string messageTemplate, params object[] values) { + Serilog.Log.Information(messageTemplate, values); + } + + /// + /// Log a templated error message to the in-game debug log. + /// + /// The message template. + /// Values to log. + public void LogError(string messageTemplate, params object[] values) + { + Serilog.Log.Error(messageTemplate, 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 void LogError(Exception exception, string messageTemplate, params object[] values) + { + Serilog.Log.Error(exception, messageTemplate, values); + } + + #endregion } }