using Microsoft.Extensions.Logging;
namespace ZB.MOM.WW.Tools.LdapProbe;
///
/// Minimal logger so the shared library's failover diagnostics are visible during a probe.
/// LdapAuthService logs a Warning per failed endpoint hop and an Information line when
/// its sticky preference moves — exactly the events a DC-failover test needs to observe.
///
public sealed class ConsoleLogger : ILogger
{
private readonly bool _verbose;
public ConsoleLogger(bool verbose) => _verbose = verbose;
public IDisposable? BeginScope(TState state) where TState : notnull => null;
public bool IsEnabled(LogLevel logLevel) => _verbose || logLevel >= LogLevel.Information;
public void Log(LogLevel logLevel, EventId eventId, TState state, Exception? exception,
Func formatter)
{
if (!IsEnabled(logLevel)) return;
var message = formatter(state, exception);
if (logLevel >= LogLevel.Warning) Ui.Warn($"[library] {message}");
else Ui.Info($"[library] {message}");
if (exception is not null && _verbose)
Ui.Info($" {RawDirectory.Describe(exception)}");
}
}