2020-08-21 13:04:13 +00:00
|
|
|
|
using OWML.Common;
|
2020-09-16 16:51:58 +00:00
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Linq;
|
2020-02-14 21:14:24 +00:00
|
|
|
|
|
2020-07-30 20:27:14 +00:00
|
|
|
|
namespace QSB.Utility
|
2020-02-15 19:48:02 +00:00
|
|
|
|
{
|
2020-12-02 21:23:01 +00:00
|
|
|
|
public static class DebugLog
|
|
|
|
|
{
|
2020-12-20 18:16:23 +00:00
|
|
|
|
public static void ToConsole(string message, MessageType type = MessageType.Message)
|
2020-12-20 16:48:04 +00:00
|
|
|
|
=> QSBCore.Helper.Console.WriteLine(message, type, GetCallingType(new StackTrace()));
|
2020-07-27 23:13:43 +00:00
|
|
|
|
|
2020-12-02 21:23:01 +00:00
|
|
|
|
public static void ToHud(string message)
|
|
|
|
|
{
|
|
|
|
|
if (Locator.GetPlayerBody() == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var data = new NotificationData(NotificationTarget.Player, message.ToUpper());
|
|
|
|
|
NotificationManager.SharedInstance.PostNotification(data);
|
|
|
|
|
}
|
2020-02-15 19:48:02 +00:00
|
|
|
|
|
2020-12-02 21:23:01 +00:00
|
|
|
|
public static void ToAll(string message, MessageType type = MessageType.Message)
|
|
|
|
|
{
|
|
|
|
|
ToConsole(message, type);
|
|
|
|
|
ToHud(message);
|
|
|
|
|
}
|
2020-08-10 16:17:54 +00:00
|
|
|
|
|
2020-12-02 21:23:01 +00:00
|
|
|
|
public static void DebugWrite(string message, MessageType type = MessageType.Message)
|
|
|
|
|
{
|
2020-12-14 16:24:52 +00:00
|
|
|
|
if (QSBCore.DebugMode)
|
2020-12-02 21:23:01 +00:00
|
|
|
|
{
|
|
|
|
|
ToConsole(message, type);
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-08-22 19:21:13 +00:00
|
|
|
|
|
2020-12-02 21:23:01 +00:00
|
|
|
|
private static string GetCallingType(StackTrace frame)
|
|
|
|
|
{
|
|
|
|
|
var stackFrame = frame.GetFrames().First(x => x.GetMethod().DeclaringType.Name != "DebugLog");
|
|
|
|
|
return stackFrame.GetMethod().DeclaringType.Name;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-12-03 08:28:05 +00:00
|
|
|
|
}
|