namespace Divergic.Logging.Xunit { using System; using global::Xunit.Abstractions; using Microsoft.Extensions.Logging; /// /// The class is used to provide Xunit logging to /// . /// public sealed class TestOutputLoggerProvider : ILoggerProvider { private readonly LoggingConfig? _config; private readonly ITestOutputHelper _output; /// /// Initializes a new instance of the class. /// /// The test output helper. /// Optional logging configuration. /// The is null. public TestOutputLoggerProvider(ITestOutputHelper output, LoggingConfig? config = null) { _output = output ?? throw new ArgumentNullException(nameof(output)); _config = config; } /// /// The is null, empty or whitespace. public ILogger CreateLogger(string categoryName) { if (string.IsNullOrWhiteSpace(categoryName)) { throw new ArgumentException("No categoryName value has been supplied", nameof(categoryName)); } return new TestOutputLogger(categoryName, _output, _config); } /// public void Dispose() { // no-op } } }