using Microsoft.Extensions.Logging; namespace Novelly.Api.Tests; public record CapturedLogEntry(LogLevel Level, string Message, Exception? Exception); public class CapturingLogger : ILogger { public List Entries { get; } = []; public IDisposable? BeginScope(TState state) where TState : notnull => null; public bool IsEnabled(LogLevel logLevel) => true; public void Log( LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func formatter) => Entries.Add(new CapturedLogEntry(logLevel, formatter(state, exception), exception)); }