using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; namespace BITKit { public static class BIT4Log { const string _debugLevel = "DebugLevel"; public static event Action OnLog; public static event Action OnException; public static event Action OnWarning; public static event Action OnSetConsoleColor; public static event Action OnNextLine; static Type currentType; [ExcuteOnAwake] public static void Start() { } [ExcuteOnStop] public static void Stop() { OnLog = null; OnException = null; OnWarning = null; OnNextLine = null; } public static void Log(object x, int debugLevel = 0, ConsoleColor color = ConsoleColor.White) { if (x is not null) { OnSetConsoleColor?.Invoke(color); OnLog?.Invoke(x.ToString()); } } public static void Log(object x, int debugLevel = 0, ConsoleColor color = ConsoleColor.White) { if (currentType == typeof(T)) { Log(x, debugLevel); } else { OnNextLine?.Invoke(); Log($"{typeof(T).Name}:{x}", debugLevel); } currentType = typeof(T); } public static void LogException(Exception e) { OnException?.Invoke(e); } public static void Warnning(object x, int debugLevel = 0) { OnWarning?.Invoke(x.ToString()); } public static void Warnning(object x, int debugLevel = 0) { Warnning($"{typeof(T).Name}:{x}", debugLevel); } } }