diff options
author | therzok <marius.ungureanu@xamarin.com> | 2019-05-30 18:02:39 +0300 |
---|---|---|
committer | therzok <marius.ungureanu@xamarin.com> | 2019-05-30 18:02:39 +0300 |
commit | 5790889871c9add4be64ef2d26a34a3f6ac5c188 (patch) | |
tree | bfadade9ca86c0eb8b82a180f560b2661c02d3c9 /main | |
parent | b315e90910728b56a11f0eecc1e768e86aebdeb2 (diff) |
Add comment on why we need to avoid appending stacktrace when we're logging an exception
Diffstat (limited to 'main')
-rw-r--r-- | main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/GLibLogging.cs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/GLibLogging.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/GLibLogging.cs index 9aaa7ceddc..21a4593f6d 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/GLibLogging.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/GLibLogging.cs @@ -287,9 +287,13 @@ namespace MonoDevelop.Ide.Gui LoggingService.LogError ("Disabling glib logging for the rest of the session"); } + static bool IsMono = Type.GetType ("Mono.Runtime") != null; + static string GetStacktraceIfNeeded (LogLevelFlags flags) { - if (flags.HasFlag (LogLevelFlags.Error | LogLevelFlags.Critical)) + // If it's an Error or a Critical message, we're going to add the stacktrace via the logged exception property, + // we don't need to append it to the message in the log. But we are only doing so on Mono, nowhere else. + if (IsMono && flags.HasFlag (LogLevelFlags.Error | LogLevelFlags.Critical)) return string.Empty; return "Stack trace: \n" + new StackTrace (1, true); @@ -306,9 +310,11 @@ namespace MonoDevelop.Ide.Gui // HACK: We need to somehow inject our stacktrace, and this is the only way we can // This is not to transform every glib error into a managed exception - typeof (Exception) - .GetField ("captured_traces", flags) - ?.SetValue (this, new StackTrace [] { trace }); + if (IsMono) { + typeof (Exception) + .GetField ("captured_traces", flags) + ?.SetValue (this, new StackTrace [] { trace }); + } } public override string StackTrace => trace.ToString (); |