breakpoint

This commit is contained in:
CortexCore
2025-01-12 11:57:37 +08:00
parent 01b3d1be43
commit 000a079985
4 changed files with 104 additions and 92 deletions

View File

@@ -8,70 +8,92 @@ using UnityEngine;
namespace BITKit
{
public static class BIT4Log
{
#if UNITY_EDITOR && UNITY_5_3_OR_NEWER
[RuntimeInitializeOnLoadMethod]
private static void Reload()
public static class BIT4Log
{
OnLog = null;
OnException = null;
OnWarning = null;
OnNextLine = null;
}
#endif
public static event Action<string> OnLog;
public static event Action<Exception> OnException;
public static event Action<string> OnWarning;
public static event Action OnNextLine;
#if UNITY_5_3_OR_NEWER
[HideInCallstack]
#if UNITY_EDITOR && UNITY_5_3_OR_NEWER
[RuntimeInitializeOnLoadMethod]
private static void Reload()
{
OnLog = null;
OnException = null;
OnWarning = null;
OnNextLine = null;
}
#endif
public static void Log(object x)
{
if (OnLog is null)
{
BITApp.ServiceProvider.GetRequiredService<ILogger<BITApp>>().LogInformation(x.ToString());
}
else
{
OnLog?.Invoke(x?.ToString());
}
}
public static event Action<string> OnLog;
public static event Action<Exception> OnException;
public static event Action<string> OnWarning;
public static event Action OnNextLine;
#if UNITY_5_3_OR_NEWER
[HideInCallstack]
[HideInCallstack]
#endif
public static void Log<T>(object x)
{
if (OnLog is null)
{
BITApp.ServiceProvider.GetRequiredService<ILogger<T>>().LogInformation(x.ToString());
}
else
{
OnLog?.Invoke(x?.ToString());
}
}
public static void Log(object x)
{
if (OnLog is not null)
{
OnLog.Invoke(x?.ToString());
return;
}
#if UNITY_5_3_OR_NEWER
[HideInCallstack]
UnityEngine.Debug.Log(x);
#endif
public static void LogException(Exception e)
{
OnException?.Invoke(e);
}
}
#if UNITY_5_3_OR_NEWER
[HideInCallstack]
[HideInCallstack]
#endif
public static void Warning(object x)
{
OnWarning?.Invoke(x.ToString());
}
public static void Log<T>(object x)
{
if (OnLog is not null)
{
OnLog.Invoke(x?.ToString());
return;
}
#if UNITY_5_3_OR_NEWER
[HideInCallstack]
UnityEngine.Debug.Log($"<b>{typeof(T).Name}</b>" + x);
#endif
public static void Warning<T>(object x)
{
Warning($"<color=#ffa500ff><b>{typeof(T).Name}</b></color>:{x}");
}
#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<T>(object x)
{
if (OnWarning is not null)
{
OnWarning.Invoke(x.ToString());
return;
}
#if UNITY_5_3_OR_NEWER
UnityEngine.Debug.LogWarning($"<b>{typeof(T).Name}</b>" + x);
#endif
}
}
}
}