2023-01-24
This commit is contained in:
36
Adaptation/_Tests/Shared/Log/DebugLogger.cs
Normal file
36
Adaptation/_Tests/Shared/Log/DebugLogger.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
|
||||
namespace Adaptation._Tests.Shared.Log;
|
||||
|
||||
public class DebugLogger : ILogger
|
||||
{
|
||||
|
||||
public int EventId { get; set; }
|
||||
|
||||
private readonly string _Name;
|
||||
private readonly LogLevel _LogLevel;
|
||||
|
||||
public DebugLogger(LogLevel logLevel, string name)
|
||||
{
|
||||
_Name = name;
|
||||
EventId = 0;
|
||||
_LogLevel = logLevel;
|
||||
if (string.IsNullOrEmpty(_Name))
|
||||
{ }
|
||||
}
|
||||
|
||||
public IDisposable BeginScope<TState>(TState state) => null;
|
||||
|
||||
public bool IsEnabled(LogLevel logLevel) => logLevel >= _LogLevel;
|
||||
|
||||
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
|
||||
{
|
||||
if (IsEnabled(logLevel) && (EventId == 0 || EventId == eventId.Id))
|
||||
{
|
||||
string message = formatter(state, null);
|
||||
System.Diagnostics.Debug.Print(message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user