diff --git a/Dalamud/Logging/PluginLog.cs b/Dalamud/Logging/PluginLog.cs index a5aad330f..b2f2a5065 100644 --- a/Dalamud/Logging/PluginLog.cs +++ b/Dalamud/Logging/PluginLog.cs @@ -27,7 +27,7 @@ public static class PluginLog /// The exception that caused the error. /// The message template. /// Values to log. - public static void Log(Exception exception, string messageTemplate, params object[] values) + public static void Log(Exception? exception, string messageTemplate, params object[] values) => WriteLog(Assembly.GetCallingAssembly().GetName().Name, LogEventLevel.Information, messageTemplate, exception, values); /// @@ -44,7 +44,7 @@ public static class PluginLog /// The exception that caused the error. /// The message template. /// Values to log. - public static void LogVerbose(Exception exception, string messageTemplate, params object[] values) + public static void LogVerbose(Exception? exception, string messageTemplate, params object[] values) => WriteLog(Assembly.GetCallingAssembly().GetName().Name, LogEventLevel.Verbose, messageTemplate, exception, values); /// @@ -61,7 +61,7 @@ public static class PluginLog /// The exception that caused the error. /// The message template. /// Values to log. - public static void LogDebug(Exception exception, string messageTemplate, params object[] values) + public static void LogDebug(Exception? exception, string messageTemplate, params object[] values) => WriteLog(Assembly.GetCallingAssembly().GetName().Name, LogEventLevel.Debug, messageTemplate, exception, values); /// @@ -78,7 +78,7 @@ public static class PluginLog /// The exception that caused the error. /// The message template. /// Values to log. - public static void LogInformation(Exception exception, string messageTemplate, params object[] values) + public static void LogInformation(Exception? exception, string messageTemplate, params object[] values) => WriteLog(Assembly.GetCallingAssembly().GetName().Name, LogEventLevel.Information, messageTemplate, exception, values); /// @@ -95,7 +95,7 @@ public static class PluginLog /// The exception that caused the error. /// The message template. /// Values to log. - public static void LogWarning(Exception exception, string messageTemplate, params object[] values) + public static void LogWarning(Exception? exception, string messageTemplate, params object[] values) => WriteLog(Assembly.GetCallingAssembly().GetName().Name, LogEventLevel.Warning, messageTemplate, exception, values); /// @@ -112,7 +112,7 @@ public static class PluginLog /// The exception that caused the error. /// The message template. /// Values to log. - public static void LogError(Exception exception, string messageTemplate, params object[] values) + public static void LogError(Exception? exception, string messageTemplate, params object[] values) => WriteLog(Assembly.GetCallingAssembly().GetName().Name, LogEventLevel.Error, messageTemplate, exception, values); /// @@ -129,7 +129,7 @@ public static class PluginLog /// The exception that caused the error. /// The message template. /// Values to log. - public static void LogFatal(Exception exception, string messageTemplate, params object[] values) + public static void LogFatal(Exception? exception, string messageTemplate, params object[] values) => WriteLog(Assembly.GetCallingAssembly().GetName().Name, LogEventLevel.Fatal, messageTemplate, exception, values); #endregion @@ -150,7 +150,7 @@ public static class PluginLog /// The exception that caused the error. /// The message template. /// Values to log. - public static void Verbose(Exception exception, string messageTemplate, params object[] values) + public static void Verbose(Exception? exception, string messageTemplate, params object[] values) => WriteLog(Assembly.GetCallingAssembly().GetName().Name, LogEventLevel.Verbose, messageTemplate, exception, values); /// @@ -167,7 +167,7 @@ public static class PluginLog /// The exception that caused the error. /// The message template. /// Values to log. - public static void Debug(Exception exception, string messageTemplate, params object[] values) + public static void Debug(Exception? exception, string messageTemplate, params object[] values) => WriteLog(Assembly.GetCallingAssembly().GetName().Name, LogEventLevel.Debug, messageTemplate, exception, values); /// @@ -184,7 +184,7 @@ public static class PluginLog /// The exception that caused the error. /// The message template. /// Values to log. - public static void Information(Exception exception, string messageTemplate, params object[] values) + public static void Information(Exception? exception, string messageTemplate, params object[] values) => WriteLog(Assembly.GetCallingAssembly().GetName().Name, LogEventLevel.Information, messageTemplate, exception, values); /// @@ -201,7 +201,7 @@ public static class PluginLog /// The exception that caused the error. /// The message template. /// Values to log. - public static void Warning(Exception exception, string messageTemplate, params object[] values) + public static void Warning(Exception? exception, string messageTemplate, params object[] values) => WriteLog(Assembly.GetCallingAssembly().GetName().Name, LogEventLevel.Warning, messageTemplate, exception, values); /// @@ -218,7 +218,7 @@ public static class PluginLog /// The exception that caused the error. /// The message template. /// Values to log. - public static void Error(Exception exception, string messageTemplate, params object[] values) + public static void Error(Exception? exception, string messageTemplate, params object[] values) => WriteLog(Assembly.GetCallingAssembly().GetName().Name, LogEventLevel.Error, messageTemplate, exception, values); /// @@ -235,11 +235,25 @@ public static class PluginLog /// The exception that caused the error. /// The message template. /// Values to log. - public static void Fatal(Exception exception, string messageTemplate, params object[] values) + 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("SourceContext", pluginName ?? string.Empty);