mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 10:17:22 +01:00
feat: serialize last exception for franzbot
This commit is contained in:
parent
1333ea7a72
commit
06b1163a52
2 changed files with 38 additions and 3 deletions
|
|
@ -196,6 +196,7 @@ namespace Dalamud
|
||||||
{
|
{
|
||||||
case Exception ex:
|
case Exception ex:
|
||||||
Log.Fatal(ex, "Unhandled exception on AppDomain");
|
Log.Fatal(ex, "Unhandled exception on AppDomain");
|
||||||
|
Troubleshooting.LogException(ex, "DalamudUnhandled");
|
||||||
|
|
||||||
var info = "Further information could not be obtained";
|
var info = "Further information could not be obtained";
|
||||||
if (ex.TargetSite != null && ex.TargetSite.DeclaringType != null)
|
if (ex.TargetSite != null && ex.TargetSite.DeclaringType != null)
|
||||||
|
|
|
||||||
|
|
@ -14,14 +14,39 @@ namespace Dalamud
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Class responsible for printing troubleshooting information to the log.
|
/// Class responsible for printing troubleshooting information to the log.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static class Troubleshooting
|
public static class Troubleshooting
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Log troubleshooting information to Serilog.
|
/// Log the last exception in a parseable format to serilog.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="exception">The exception to log.</param>
|
||||||
|
/// <param name="context">Additional context.</param>
|
||||||
|
public static void LogException(Exception exception, string context)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var payload = new ExceptionPayload
|
||||||
|
{
|
||||||
|
Context = context,
|
||||||
|
When = DateTime.Now,
|
||||||
|
Info = exception.ToString(),
|
||||||
|
};
|
||||||
|
|
||||||
|
var encodedPayload = Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(payload)));
|
||||||
|
Log.Information($"LASTEXCEPTION:{encodedPayload}");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.Error(ex, "Could not print exception.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Log troubleshooting information in a parseable format to Serilog.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dalamud">The <see cref="Dalamud"/> instance to read information from.</param>
|
/// <param name="dalamud">The <see cref="Dalamud"/> instance to read information from.</param>
|
||||||
/// <param name="isInterfaceLoaded">Whether or not the interface was loaded.</param>
|
/// <param name="isInterfaceLoaded">Whether or not the interface was loaded.</param>
|
||||||
public static void LogTroubleshooting(Dalamud dalamud, bool isInterfaceLoaded)
|
internal static void LogTroubleshooting(Dalamud dalamud, bool isInterfaceLoaded)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -47,6 +72,15 @@ namespace Dalamud
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class ExceptionPayload
|
||||||
|
{
|
||||||
|
public DateTime When { get; set; }
|
||||||
|
|
||||||
|
public string Info { get; set; }
|
||||||
|
|
||||||
|
public string Context { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
private class TroubleshootingPayload
|
private class TroubleshootingPayload
|
||||||
{
|
{
|
||||||
public PluginManifest[] LoadedPlugins { get; set; }
|
public PluginManifest[] LoadedPlugins { get; set; }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue