/// <summary> /// Adds an xunit logger to the logging builder. /// </summary> /// <param name="builder">The <see cref="ILoggingBuilder"/> to use.</param> /// <param name="accessor">The <see cref="IMessageSinkAccessor"/> to use.</param> /// <returns> /// The instance of <see cref="ILoggingBuilder"/> specified by <paramref name="builder"/>. /// </returns> /// <exception cref="ArgumentNullException"> /// <paramref name="builder"/> or <paramref name="accessor"/> is <see langword="null"/>. /// </exception> public static ILoggingBuilder AddXUnit(this ILoggingBuilder builder, IMessageSinkAccessor accessor) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } if (accessor == null) { throw new ArgumentNullException(nameof(accessor)); } return(builder.AddXUnit(accessor, static (_) => { }));
/// <summary> /// Initializes a new instance of the <see cref="XUnitLogger"/> class. /// </summary> /// <param name="name">The name for messages produced by the logger.</param> /// <param name="accessor">The <see cref="IMessageSinkAccessor"/> to use.</param> /// <param name="options">The <see cref="XUnitLoggerOptions"/> to use.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="name"/> or <paramref name="accessor"/> is <see langword="null"/>. /// </exception> public XUnitLogger(string name, IMessageSinkAccessor accessor, XUnitLoggerOptions?options) : this(name, options) { _messageSinkAccessor = accessor ?? throw new ArgumentNullException(nameof(accessor)); }
/// <summary> /// Initializes a new instance of the <see cref="XUnitLoggerProvider"/> class. /// </summary> /// <param name="accessor">The <see cref="IMessageSinkAccessor"/> to use.</param> /// <param name="options">The options to use for logging to xunit.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="accessor"/> or <paramref name="options"/> is <see langword="null"/>. /// </exception> public XUnitLoggerProvider(IMessageSinkAccessor accessor, XUnitLoggerOptions options) { _messageSinkAccessor = accessor ?? throw new ArgumentNullException(nameof(accessor)); _options = options ?? throw new ArgumentNullException(nameof(options)); }