27 lines
683 B
C#
27 lines
683 B
C#
using Microsoft.Extensions.Logging;
|
|
using System;
|
|
using System.Collections.Concurrent;
|
|
|
|
namespace Adaptation._Tests.Shared.Log;
|
|
|
|
public class DebugProvider : ILoggerProvider
|
|
{
|
|
|
|
private readonly LogLevel _LogLevel;
|
|
private readonly ConcurrentDictionary<string, DebugLogger> _Loggers;
|
|
|
|
public DebugProvider(LogLevel logLevel)
|
|
{
|
|
_LogLevel = logLevel;
|
|
_Loggers = new ConcurrentDictionary<string, DebugLogger>();
|
|
}
|
|
|
|
public ILogger CreateLogger(string categoryName) => _Loggers.GetOrAdd(categoryName, name => new DebugLogger(_LogLevel, name));
|
|
|
|
public void Dispose()
|
|
{
|
|
_Loggers.Clear();
|
|
GC.SuppressFinalize(this);
|
|
}
|
|
|
|
} |