Path: redb-route/tests/redb.Route.Tests/Cluster/CapturingLoggerProvider.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests/Cluster/CapturingLoggerProvider.cs ---- using System.Collections.Concurrent; using Microsoft.Extensions.Logging; namespace redb.Route.Tests.Cluster; /// /// Test-only logger provider that captures every log entry into an in-memory list, /// for assertions on warning messages emitted during route compilation. /// internal sealed class CapturingLoggerProvider : ILoggerProvider { public ConcurrentBag Entries { get; } = new(); public ILogger CreateLogger(string categoryName) => new Logger(this, categoryName); public void Dispose() { } internal sealed record LogEntry(string Category, LogLevel Level, string Message, Exception? Exception); private sealed class Logger : ILogger { private readonly CapturingLoggerProvider _owner; private readonly string _category; public Logger(CapturingLoggerProvider owner, string category) { _owner = owner; _category = category; } 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) { _owner.Entries.Add(new LogEntry(_category, logLevel, formatter(state, exception), exception)); } } }