Files
caliverse_server/ServerCore/Dump/DumpHelper.cs
2025-05-01 07:20:41 +09:00

42 lines
1.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace ServerCore;
public static class DumpHelper
{
public static DumpConfig DumpConfig;
private static void unhandledExceptionHandler(object sender, UnhandledExceptionEventArgs e)
{
// 윈도우 덤프 경로: C:\Users\xxxxxx\AppData\Local\CrashDumps
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
Exception ex = (Exception)e.ExceptionObject;
MiniDump.write(DumpConfig, ex);
}
}
public static void init(string dumpPath, string name)
{
DumpConfig.DumpFile = $"{dumpPath}\\{name}_{DateTime.Now.Ticks}.dmp";
DumpConfig.TxtFile = $"{dumpPath}\\{name}_{DateTime.Now.Ticks}.txt";
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(DumpHelper.unhandledExceptionHandler);
}
else
{
AppDomain.CurrentDomain.UnhandledException += DumpHandler.unhandledExceptionHandler;
}
}
}