This commit is contained in:
CortexCore
2023-10-24 23:38:22 +08:00
parent 2c4710bc5d
commit bd40165ade
152 changed files with 3681 additions and 1531 deletions

View File

@@ -1,11 +1,15 @@
using System;
using System.Diagnostics;
#if UNITY_64
using UnityEngine;
#endif
namespace BITKit
{
public static class BIT4Log
{
#if UNITY_EDITOR
[UnityEngine.RuntimeInitializeOnLoadMethod]
[RuntimeInitializeOnLoadMethod]
private static void Reload()
{
OnLog = null;
@@ -21,12 +25,17 @@ namespace BITKit
public static event Action<ConsoleColor> OnSetConsoleColor;
public static event Action OnNextLine;
private static Type currentType;
#if UNITY_64
[HideInCallstack]
#endif
public static void Log(object x, int debugLevel = 0, ConsoleColor color = ConsoleColor.White)
{
OnSetConsoleColor?.Invoke(color);
OnLog?.Invoke(x?.ToString());
}
#if UNITY_64
[HideInCallstack]
#endif
public static void Log<T>(object x, int debugLevel = 0, ConsoleColor color = ConsoleColor.White)
{
if (currentType != typeof(T))
@@ -41,15 +50,23 @@ namespace BITKit
currentType = typeof(T);
}
#if UNITY_64
[HideInCallstack]
#endif
public static void LogException(Exception e)
{
OnException?.Invoke(e);
}
#if UNITY_64
[HideInCallstack]
#endif
public static void Warning(object x, int debugLevel = 0)
{
OnWarning?.Invoke(x.ToString());
}
#if UNITY_64
[HideInCallstack]
#endif
public static void Warning<T>(object x, int debugLevel = 0)
{
Warning($"{typeof(T).Name}:{x}", debugLevel);