// ReSharper disable once CheckNamespace namespace Microsoft.Extensions.Logging { using System; using Divergic.Logging.Xunit; using Xunit.Abstractions; /// /// The /// class provides extension methods for the interface. /// public static class LoggingBuilderExtensions { /// /// Adds a logger to writes to the xUnit test output to the specified logging builder. /// /// The logging builder. /// The xUnit test output helper. /// Optional logging configuration. public static void AddXunit(this ILoggingBuilder builder, ITestOutputHelper output, LoggingConfig? config = null) { builder = builder ?? throw new ArgumentNullException(nameof(builder)); output = output ?? throw new ArgumentNullException(nameof(output)); // Object is added as a provider to the builder and cannot be disposed of here #pragma warning disable CA2000 // Dispose objects before losing scope var provider = new TestOutputLoggerProvider(output, config); #pragma warning restore CA2000 // Dispose objects before losing scope builder.AddProvider(provider); } } }