dep08siasm/Adaptation/_Tests/Shared/Log/ConsoleProvider.cs
Mike Phares 5cda494708 Infineon.EAF.Runtime v2.59.0
With .gitignore *.traineddata
2025-02-21 13:47:08 -07:00

27 lines
693 B
C#

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