Path: redb/redb.Tests.Integration/Fixtures/CapturingLoggerProvider.cs Snapshot: redb, 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 Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Fixtures/CapturingLoggerProvider.cs ---- using System.Collections.Concurrent; using Microsoft.Extensions.Logging; namespace redb.Tests.Integration.Fixtures; /// /// Records every log entry of the loggers it creates, so a test can assert that a diagnostic warning was /// written - and written once. /// public sealed class CapturingLoggerProvider : ILoggerProvider { private readonly ConcurrentQueue _entries = new(); public IReadOnlyList Entries => _entries.ToArray(); /// Messages of the Warning entries, in the order they were written. public IReadOnlyList Warnings => _entries.Where(e => e.Level == LogLevel.Warning).Select(e => e.Message).ToList(); public ILogger CreateLogger(string categoryName) => new CapturingLogger(this, categoryName); public void Dispose() { } private sealed class CapturingLogger : ILogger { private readonly CapturingLoggerProvider _owner; private readonly string _category; public CapturingLogger(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.Enqueue(new CapturedLogEntry(_category, logLevel, formatter(state, exception))); } } public sealed record CapturedLogEntry(string Category, LogLevel Level, string Message);