From d57eba7f631d36ba6cd379dbbadf1715c4b0386c Mon Sep 17 00:00:00 2001 From: Kaz Wolfe Date: Fri, 10 Feb 2023 22:36:34 -0800 Subject: [PATCH] feat: Add LogRaw to PluginLog Adds the ability to send a log message to Serilog specifying a log level at runtime. This feature is primarily aimed at allowing developers to easily bridge disparate logging systems without hardcoding log level calls. --- Dalamud/Logging/PluginLog.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Dalamud/Logging/PluginLog.cs b/Dalamud/Logging/PluginLog.cs index a5aad330f..80edbe430 100644 --- a/Dalamud/Logging/PluginLog.cs +++ b/Dalamud/Logging/PluginLog.cs @@ -240,6 +240,20 @@ public static class PluginLog #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("SourceContext", pluginName ?? string.Empty);