27 lines
		
	
	
		
			693 B
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			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);
 | |
|     }
 | |
| 
 | |
| } |