1
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user