diff --git a/CommonHelpers/Instance.cs b/CommonHelpers/Instance.cs index 0d32d72..63372a2 100644 --- a/CommonHelpers/Instance.cs +++ b/CommonHelpers/Instance.cs @@ -155,7 +155,7 @@ namespace CommonHelpers { if (!runOnceMutex.WaitOne(runOnceTimeout)) { - Fatal(title, "Run many times"); + Fatal(title, "Run many times", false); } } catch (AbandonedMutexException) @@ -249,8 +249,10 @@ namespace CommonHelpers catch { } } - public static void Fatal(String? title, String message) + public static void Fatal(String? title, String message, bool capture = true) { + if (capture) + Log.TraceError("FATAL: {0}", message); if (title is not null) MessageBox.Show(message, title, MessageBoxButtons.OK, MessageBoxIcon.Error); Environment.Exit(1); diff --git a/CommonHelpers/Log.cs b/CommonHelpers/Log.cs index 2bb8811..48723c2 100644 --- a/CommonHelpers/Log.cs +++ b/CommonHelpers/Log.cs @@ -47,6 +47,16 @@ namespace CommonHelpers Console.WriteLine(line); } + public static void TraceError(string format, params object?[] arg) + { + String line = string.Format(format, arg); + Sentry.SentrySdk.CaptureMessage(line, Sentry.SentryLevel.Error); + if (LogToTrace) + Trace.WriteLine(line); + if (LogToConsole) + Console.WriteLine(line); + } + public static void TraceException(String type, Object? name, Exception e) { TraceLine("{0}: {1}: Exception: {2}", type, name, e);