diff --git a/src/NetEvolve.Logging.XUnit/XUnitLogger.cs b/src/NetEvolve.Logging.XUnit/XUnitLogger.cs index c2791e6..c837f93 100644 --- a/src/NetEvolve.Logging.XUnit/XUnitLogger.cs +++ b/src/NetEvolve.Logging.XUnit/XUnitLogger.cs @@ -4,7 +4,6 @@ using System.Globalization; using System.Text; using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Primitives; using NetEvolve.Arguments; using NetEvolve.Logging.Abstractions; using Xunit.Abstractions; @@ -35,6 +34,19 @@ public class XUnitLogger : ILogger, ISupportExternalScope /// public IReadOnlyList LoggedMessages => _loggedMessages.AsReadOnly(); + /// + /// Creates a new instance of . + /// + /// The to write the log messages to. + /// The to use to get the current scope. + /// The options to control the behavior of the logger. + /// A cached or new instance of . + public static XUnitLogger CreateLogger( + IMessageSink messageSink, + IExternalScopeProvider? scopeProvider = null, + IXUnitLoggerOptions? options = null + ) => CreateLogger(messageSink, TimeProvider.System, scopeProvider, options); + /// /// Creates a new instance of . /// @@ -51,10 +63,26 @@ public static XUnitLogger CreateLogger( ) { Argument.ThrowIfNull(messageSink); + Argument.ThrowIfNull(timeProvider); return new XUnitLogger(messageSink, timeProvider, scopeProvider, options); } + /// + /// Creates a new instance of . + /// + /// The type who's fullname is used as the category name for messages produced by the logger. + /// The to write the log messages to. + /// The to use to get the current scope. + /// The options to control the behavior of the logger. + /// A cached or new instance of . + public static XUnitLogger CreateLogger( + IMessageSink messageSink, + IExternalScopeProvider? scopeProvider = null, + IXUnitLoggerOptions? options = null + ) + where T : notnull => CreateLogger(messageSink, scopeProvider, options); + /// /// Creates a new instance of . /// @@ -72,6 +100,19 @@ public static XUnitLogger CreateLogger( ) where T : notnull => new XUnitLogger(messageSink, timeProvider, scopeProvider, options); + /// + /// Creates a new instance of . + /// + /// The to write the log messages to. + /// The to use to get the current scope. + /// The options to control the behavior of the logger. + /// A cached or new instance of . + public static XUnitLogger CreateLogger( + ITestOutputHelper testOutputHelper, + IExternalScopeProvider? scopeProvider = null, + IXUnitLoggerOptions? options = null + ) => CreateLogger(testOutputHelper, TimeProvider.System, scopeProvider, options); + /// /// Creates a new instance of . /// @@ -88,10 +129,27 @@ public static XUnitLogger CreateLogger( ) { Argument.ThrowIfNull(testOutputHelper); + Argument.ThrowIfNull(timeProvider); return new XUnitLogger(testOutputHelper, timeProvider, scopeProvider, options); } + /// + /// Creates a new instance of . + /// + /// The type who's fullname is used as the category name for messages produced by the logger. + /// The to write the log messages to. + /// The to use to get the current scope. + /// The options to control the behavior of the logger. + /// A cached or new instance of . + public static XUnitLogger CreateLogger( + ITestOutputHelper testOutputHelper, + IExternalScopeProvider? scopeProvider = null, + IXUnitLoggerOptions? options = null + ) + where T : notnull => + CreateLogger(testOutputHelper, TimeProvider.System, scopeProvider, options); + /// /// Creates a new instance of . ///