This commit is contained in:
JohnCorby 2022-08-05 14:32:21 -07:00
parent f6d8f0ffa1
commit c7d9ee204a

View File

@ -1,9 +1,7 @@
using OWML.Common; using OWML.Common;
using OWML.Logging; using OWML.Logging;
using QSB.WorldSync;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using UnityEngine;
namespace QSB.Utility; namespace QSB.Utility;
@ -19,7 +17,7 @@ public static class DebugLog
message = $"[{ProcessInstanceId}] " + message; message = $"[{ProcessInstanceId}] " + message;
} }
QSBCore.Helper.Console.WriteLine(message, type, GetCallingType(new StackTrace())); QSBCore.Helper.Console.WriteLine(message, type, GetCallingType());
} }
public static void ToHud(string message) public static void ToHud(string message)
@ -44,7 +42,7 @@ public static class DebugLog
if (QSBCore.Helper == null) if (QSBCore.Helper == null)
{ {
// yes i know this is only meant for OWML, but it's useful as a backup // yes i know this is only meant for OWML, but it's useful as a backup
ModConsole.OwmlConsole.WriteLine(message, type, GetCallingType(new StackTrace())); ModConsole.OwmlConsole.WriteLine(message, type, GetCallingType());
return; return;
} }
@ -54,8 +52,9 @@ public static class DebugLog
} }
} }
private static string GetCallingType(StackTrace frame) => private static string GetCallingType() =>
frame.GetFrames()! new StackTrace(2) // skip this function and calling function
.GetFrames()!
.Select(x => x.GetMethod().DeclaringType!.Name) .Select(x => x.GetMethod().DeclaringType!.Name)
.First(x => x != nameof(DebugLog)); .First(x => x != nameof(DebugLog));
} }