better logging

This commit is contained in:
Mister_Nebula 2020-09-16 17:51:58 +01:00
parent f4984b1e9f
commit 70bca00d87
2 changed files with 29 additions and 2 deletions

View File

@ -14,7 +14,7 @@ namespace QSB.OrbSync
}
}
public static bool CheckOrbCollision(ref bool __result, NomaiInterfaceSlot __instance, NomaiInterfaceOrb orb,
public static bool CheckOrbCollision(ref bool __result, NomaiInterfaceSlot __instance, NomaiInterfaceOrb orb,
bool ____ignoreDraggedOrbs, float ____radius, float ____exitRadius, ref NomaiInterfaceOrb ____occupyingOrb)
{
if (____ignoreDraggedOrbs && orb.IsBeingDragged())

View File

@ -1,4 +1,7 @@
using OWML.Common;
using OWML.Logging;
using System.Diagnostics;
using System.Linq;
namespace QSB.Utility
{
@ -6,7 +9,20 @@ namespace QSB.Utility
{
public static void ToConsole(string message, MessageType type = MessageType.Message)
{
QSB.Helper.Console.WriteLine(message, type);
var console = (ModSocketOutput)QSB.Helper.Console;
var method = console.GetType()
.GetMethods(System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)
.Last(x => x.Name == "WriteLine");
var callingType = GetCallingType(new StackTrace());
if (callingType == "DebugLog")
{
callingType = GetCallingType(new StackTrace(), 2);
}
if (callingType == "DebugLog")
{
callingType = GetCallingType(new StackTrace(), 3);
}
method.Invoke(console, new object[] { type, message, callingType });
}
public static void ToHud(string message)
@ -40,5 +56,16 @@ namespace QSB.Utility
DebugWrite($"* {name} {status}", messageType);
}
private static string GetCallingType(StackTrace frame, int index = 1)
{
try
{
return frame.GetFrame(index).GetMethod().DeclaringType.Name;
}
catch
{
return "";
}
}
}
}