using System; using System.Diagnostics; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; #if UNITY_5_3_OR_NEWER using UnityEngine; #endif namespace BITKit { public static class BIT4Log { #if UNITY_EDITOR && UNITY_5_3_OR_NEWER [RuntimeInitializeOnLoadMethod] private static void Reload() { OnLog = null; OnException = null; OnWarning = null; OnNextLine = null; } #endif public static event Action OnLog = Console.WriteLine; public static event Action OnException = Console.WriteLine; public static event Action OnWarning = Console.WriteLine; public static event Action OnNextLine=Console.WriteLine; #if UNITY_5_3_OR_NEWER [HideInCallstack] #endif public static void Log(object x) { if (OnLog is not null) { OnLog.Invoke(x?.ToString()); return; } #if UNITY_5_3_OR_NEWER UnityEngine.Debug.Log(x); #endif } #if UNITY_5_3_OR_NEWER [HideInCallstack] #endif public static void Log(object x) { if (OnLog is not null) { OnLog.Invoke(x?.ToString()); return; } #if UNITY_5_3_OR_NEWER UnityEngine.Debug.Log($"{typeof(T).Name}" + x); #endif } #if UNITY_5_3_OR_NEWER [HideInCallstack] #endif public static void LogException(Exception e) { if (OnException is not null) { OnException.Invoke(e); return; } #if UNITY_5_3_OR_NEWER UnityEngine.Debug.LogException(e); #endif } #if UNITY_5_3_OR_NEWER [HideInCallstack] #endif public static void Warning(object x) { if (OnWarning is not null) { OnWarning.Invoke(x.ToString()); return; } #if UNITY_5_3_OR_NEWER UnityEngine.Debug.LogWarning(x); #endif } #if UNITY_5_3_OR_NEWER [HideInCallstack] #endif public static void Warning(object x) { if (OnWarning is not null) { OnWarning.Invoke(x.ToString()); return; } #if UNITY_5_3_OR_NEWER UnityEngine.Debug.LogWarning($"{typeof(T).Name}" + x); #endif } } }