mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-01-02 13:53:40 +01:00
feat: print all logged exceptions via Troubleshooting
This commit is contained in:
parent
25a71574cf
commit
59ba3bdd07
3 changed files with 16 additions and 5 deletions
|
|
@ -19,6 +19,7 @@ using Dalamud.Game.Text.SeStringHandling;
|
||||||
using Dalamud.Hooking.Internal;
|
using Dalamud.Hooking.Internal;
|
||||||
using Dalamud.Interface.Internal;
|
using Dalamud.Interface.Internal;
|
||||||
using Dalamud.IoC.Internal;
|
using Dalamud.IoC.Internal;
|
||||||
|
using Dalamud.Logging.Internal;
|
||||||
using Dalamud.Plugin.Internal;
|
using Dalamud.Plugin.Internal;
|
||||||
using Dalamud.Plugin.Ipc.Internal;
|
using Dalamud.Plugin.Ipc.Internal;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
|
@ -101,6 +102,8 @@ namespace Dalamud
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
SerilogEventSink.Instance.LogLine += SerilogOnLogLine;
|
||||||
|
|
||||||
Service<ServiceContainer>.Set();
|
Service<ServiceContainer>.Set();
|
||||||
|
|
||||||
// Initialize the process information.
|
// Initialize the process information.
|
||||||
|
|
@ -393,6 +396,14 @@ namespace Dalamud
|
||||||
// Log.Verbose($"Process.Handle // {__instance.ProcessName} // {__result:X}");
|
// Log.Verbose($"Process.Handle // {__instance.ProcessName} // {__result:X}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void SerilogOnLogLine(object? sender, (string Line, LogEventLevel Level, DateTimeOffset TimeStamp, Exception? Exception) e)
|
||||||
|
{
|
||||||
|
if (e.Exception == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Troubleshooting.LogException(e.Exception, e.Line);
|
||||||
|
}
|
||||||
|
|
||||||
private void ApplyProcessPatch()
|
private void ApplyProcessPatch()
|
||||||
{
|
{
|
||||||
var harmony = new Harmony("goatcorp.dalamud");
|
var harmony = new Harmony("goatcorp.dalamud");
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ namespace Dalamud.Interface.Internal.Windows
|
||||||
|
|
||||||
this.autoScroll = configuration.LogAutoScroll;
|
this.autoScroll = configuration.LogAutoScroll;
|
||||||
this.openAtStartup = configuration.LogOpenAtStartup;
|
this.openAtStartup = configuration.LogOpenAtStartup;
|
||||||
SerilogEventSink.Instance.OnLogLine += this.OnLogLine;
|
SerilogEventSink.Instance.LogLine += this.OnLogLine;
|
||||||
|
|
||||||
this.Size = new Vector2(500, 400);
|
this.Size = new Vector2(500, 400);
|
||||||
this.SizeCondition = ImGuiCond.FirstUseEver;
|
this.SizeCondition = ImGuiCond.FirstUseEver;
|
||||||
|
|
@ -68,7 +68,7 @@ namespace Dalamud.Interface.Internal.Windows
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
SerilogEventSink.Instance.OnLogLine -= this.OnLogLine;
|
SerilogEventSink.Instance.LogLine -= this.OnLogLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -476,7 +476,7 @@ namespace Dalamud.Interface.Internal.Windows
|
||||||
_ => throw new ArgumentOutOfRangeException(level.ToString(), "Invalid LogEventLevel"),
|
_ => throw new ArgumentOutOfRangeException(level.ToString(), "Invalid LogEventLevel"),
|
||||||
};
|
};
|
||||||
|
|
||||||
private void OnLogLine(object sender, (string Line, LogEventLevel Level, DateTimeOffset Offset) logEvent)
|
private void OnLogLine(object sender, (string Line, LogEventLevel Level, DateTimeOffset Offset, Exception? Exception) logEvent)
|
||||||
{
|
{
|
||||||
this.HandleLogLine(logEvent.Line, logEvent.Level, logEvent.Offset);
|
this.HandleLogLine(logEvent.Line, logEvent.Level, logEvent.Offset);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ namespace Dalamud.Logging.Internal
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Event on a log line being emitted.
|
/// Event on a log line being emitted.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event EventHandler<(string Line, LogEventLevel Level, DateTimeOffset TimeStamp)> OnLogLine;
|
public event EventHandler<(string Line, LogEventLevel Level, DateTimeOffset TimeStamp, Exception? Exception)>? LogLine;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the default instance.
|
/// Gets the default instance.
|
||||||
|
|
@ -45,7 +45,7 @@ namespace Dalamud.Logging.Internal
|
||||||
message += "\n" + logEvent.Exception;
|
message += "\n" + logEvent.Exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.OnLogLine?.Invoke(this, (message, logEvent.Level, logEvent.Timestamp));
|
this.LogLine?.Invoke(this, (message, logEvent.Level, logEvent.Timestamp, logEvent.Exception));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue