mirror of
https://github.com/Sea-Haven-Industries/proposal-system.git
synced 2026-09-30 15:53:15 +00:00
23 lines
578 B
C#
23 lines
578 B
C#
|
|
using Microsoft.Extensions.Logging;
|
||
|
|
|
||
|
|
namespace ProposalSystem.Tests.Helpers;
|
||
|
|
|
||
|
|
internal sealed class CapturingLogger<T> : ILogger<T>
|
||
|
|
{
|
||
|
|
public List<string> Messages { get; } = [];
|
||
|
|
|
||
|
|
public IDisposable? BeginScope<TState>(TState state) where TState : notnull => null;
|
||
|
|
|
||
|
|
public bool IsEnabled(LogLevel logLevel) => true;
|
||
|
|
|
||
|
|
public void Log<TState>(
|
||
|
|
LogLevel logLevel,
|
||
|
|
EventId eventId,
|
||
|
|
TState state,
|
||
|
|
Exception? exception,
|
||
|
|
Func<TState, Exception?, string> formatter)
|
||
|
|
{
|
||
|
|
Messages.Add(formatter(state, exception));
|
||
|
|
}
|
||
|
|
}
|