This commit is contained in:
CortexCore
2025-03-09 13:38:23 +08:00
parent 8261a458e2
commit 18239a5ae4
67 changed files with 8573 additions and 831 deletions

View File

@@ -7,37 +7,6 @@ using ILogger = Microsoft.Extensions.Logging.ILogger;
namespace BITKit
{
public abstract class UnityLogger:ILogger
{
[HideInCallstack]
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
{
switch (logLevel)
{
case LogLevel.Critical:
case LogLevel.Error:
if (exception is not null)
{
Debug.LogException(exception);
}
else
{
Debug.LogError($"{CurrentScope}:{state.ToString()}");
}
break;
default:
Debug.Log($"{CurrentScope}:{state.ToString()}");
break;
}
}
public bool IsEnabled(LogLevel logLevel) => true;
private string CurrentScope { get; set; }
public IDisposable BeginScope<TState>(TState state) where TState : notnull
{
CurrentScope = typeof(TState).Name;
return null;
}
}
public sealed class UnityLogger<T>:ILogger<T>
{
[HideInCallstack]
@@ -53,11 +22,11 @@ namespace BITKit
}
else
{
Debug.LogError($"{typeof(T).Name}:{state.ToString()}");
Debug.LogError($"{typeof(T).CSharpName()}:{state.ToString()}");
}
break;
default:
Debug.Log($"<b>{typeof(T).Name}</b>:{state.ToString()}");
Debug.Log($"<b>{typeof(T).CSharpName()}</b>:{state.ToString()}");
break;
}
}