using Microsoft.Extensions.Logging;
namespace ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.Tests;
/// Thread-safe capturing logger shared by the remediation tests (poll loops log from pool threads).
internal sealed class AbLegacyTestLogger : ILogger
{
/// Every entry logged, in order.
public System.Collections.Concurrent.ConcurrentQueue<(LogLevel Level, string Message)> Entries { get; } = new();
/// The Warning-level messages logged.
public IReadOnlyList Warnings => [.. Entries.Where(e => e.Level == LogLevel.Warning).Select(e => e.Message)];
///
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.Enqueue((logLevel, formatter(state, exception)));
}