This commit is contained in:
Sardelka
2022-08-15 21:25:42 +08:00
parent cb91486848
commit ae10da874b

View File

@ -10,9 +10,11 @@ namespace RageCoop.Server
class Program
{
private static bool Stopping = false;
static Logger mainLogger;
static void Main(string[] args)
{
var mainLogger= new Logger()
AppDomain.CurrentDomain.UnhandledException+=UnhandledException;
mainLogger = new Logger()
{
LogPath="RageCoop.Server.log",
UseConsole=true,
@ -65,6 +67,18 @@ namespace RageCoop.Server
}
}
catch (Exception e)
{
Fatal(e);
}
}
private static void UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
mainLogger.Error($"Unhandled exception thrown from user thread:",e.ExceptionObject as Exception);
mainLogger.Flush();
}
static void Fatal(Exception e)
{
mainLogger.Error(e);
mainLogger.Error($"Fatal error occurred, server shutting down.");
@ -74,4 +88,3 @@ namespace RageCoop.Server
}
}
}
}