aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx/Program.cs
diff options
context:
space:
mode:
authoremmauss <emmausssss@gmail.com>2019-01-31 04:49:15 +0200
committergdkchan <gab.dark.100@gmail.com>2019-01-30 23:49:15 -0300
commitc81abdde4c48c607669580ef769776623b86dcc7 (patch)
tree03a599b9ff513bbf0eeef10402f1b36fd9a70c7a /Ryujinx/Program.cs
parentc1bdf19061ec679aa3c69eda2a41337e3e809014 (diff)
Add file logging and handle unhandled exceptions (#558)
* add unhandled exception handler * added file logging * add option in config * consolidated console and file log
Diffstat (limited to 'Ryujinx/Program.cs')
-rw-r--r--Ryujinx/Program.cs22
1 files changed, 21 insertions, 1 deletions
diff --git a/Ryujinx/Program.cs b/Ryujinx/Program.cs
index 4dce13c7..335aa0ea 100644
--- a/Ryujinx/Program.cs
+++ b/Ryujinx/Program.cs
@@ -22,7 +22,10 @@ namespace Ryujinx
Config.Read(device);
- Logger.Updated += ConsoleLog.Log;
+ Logger.Updated += Log.LogMessage;
+
+ AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
+ AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit;
if (args.Length == 1)
{
@@ -87,6 +90,23 @@ namespace Ryujinx
audioOut.Dispose();
}
+ private static void CurrentDomain_ProcessExit(object sender, EventArgs e)
+ {
+ Log.Close();
+ }
+
+ private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
+ {
+ var exception = e.ExceptionObject as Exception;
+
+ Logger.PrintError(LogClass.Emulation, $"Unhandled exception caught: {exception}");
+
+ if (e.IsTerminating)
+ {
+ Log.Close();
+ }
+ }
+
/// <summary>
/// Picks an <see cref="IAalOutput"/> audio output renderer supported on this machine
/// </summary>