1
0
mirror of https://github.com/Ylianst/MeshCentralRouter synced 2026-02-22 12:23:24 +00:00

improved debug log.

This commit is contained in:
Ylian Saint-Hilaire
2020-09-26 11:17:32 -07:00
parent ac2dc4a255
commit 2f9aebb56e
5 changed files with 36 additions and 1 deletions

View File

@@ -15,6 +15,7 @@ limitations under the License.
*/
using System;
using System.IO;
using System.Windows.Forms;
namespace MeshCentralRouter
@@ -33,6 +34,10 @@ namespace MeshCentralRouter
Application.SetCompatibleTextRenderingDefault(false);
Properties.Settings.Default.Upgrade();
Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(ExceptionSink);
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledExceptionEventSink);
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException, true);
foreach (string arg in args)
{
if (arg.Length > 3 && string.Compare(arg.Substring(0, 3), "-l:", true) == 0) {
@@ -51,5 +56,16 @@ namespace MeshCentralRouter
while (currentCulture.Equals(System.Threading.Thread.CurrentThread.CurrentUICulture) == false);
}
public static void Debug(string msg) { try { File.AppendAllText("debug.log", msg + "\r\n"); } catch (Exception) { } }
public static void ExceptionSink(object sender, System.Threading.ThreadExceptionEventArgs args)
{
Debug("ExceptionSink: " + args.Exception.ToString());
}
public static void UnhandledExceptionEventSink(object sender, UnhandledExceptionEventArgs args)
{
Debug("UnhandledExceptionEventSink: " + ((Exception)args.ExceptionObject).ToString());
}
}
}