mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 10:17:22 +01:00
Add crash handler stuff.
This commit is contained in:
parent
9ba6e4d0af
commit
e08e9c4d13
35 changed files with 1472 additions and 237 deletions
30
Penumbra.CrashHandler/Program.cs
Normal file
30
Penumbra.CrashHandler/Program.cs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
using System.Diagnostics;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Penumbra.CrashHandler;
|
||||
|
||||
public class CrashHandler
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
if (args.Length < 2 || !int.TryParse(args[1], out var pid))
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
using var reader = new GameEventLogReader();
|
||||
var parent = Process.GetProcessById(pid);
|
||||
|
||||
parent.WaitForExit();
|
||||
var exitCode = parent.ExitCode;
|
||||
var obj = reader.Dump("Crash", pid, exitCode);
|
||||
using var fs = File.Open(args[0], FileMode.Create);
|
||||
using var w = new Utf8JsonWriter(fs, new JsonWriterOptions { Indented = true });
|
||||
obj.WriteTo(w, new JsonSerializerOptions() { WriteIndented = true });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
File.WriteAllText(args[0], $"{DateTime.UtcNow} {pid} {ex}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue