1
This commit is contained in:
@@ -7,8 +7,9 @@ using ILogger = Microsoft.Extensions.Logging.ILogger;
|
||||
|
||||
namespace BITKit
|
||||
{
|
||||
public sealed class UnityLogger:ILogger
|
||||
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)
|
||||
@@ -37,15 +38,37 @@ namespace BITKit
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public sealed class UnityLoggerProvider:ILoggerProvider
|
||||
public sealed class UnityLogger<T>:ILogger<T>
|
||||
{
|
||||
public void Dispose()
|
||||
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($"{typeof(T).Name}:{state.ToString()}");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Debug.Log($"{typeof(T).Name}:{state.ToString()}");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public ILogger CreateLogger(string categoryName)
|
||||
public bool IsEnabled(LogLevel logLevel)
|
||||
{
|
||||
return new UnityLogger();
|
||||
return true;
|
||||
}
|
||||
|
||||
public IDisposable BeginScope<TState>(TState state) where TState : notnull
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user