From 0eacf1f2cebfbb058cb7843c521bfc5324fa34ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20St=C3=BChmer?= Date: Thu, 23 May 2024 15:41:57 +0200 Subject: [PATCH 1/2] chore: Added missing `CreateLogger` overloads --- src/NetEvolve.Logging.XUnit/XUnitLogger.cs | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/src/NetEvolve.Logging.XUnit/XUnitLogger.cs b/src/NetEvolve.Logging.XUnit/XUnitLogger.cs index c2791e6..2ba7881 100644 --- a/src/NetEvolve.Logging.XUnit/XUnitLogger.cs +++ b/src/NetEvolve.Logging.XUnit/XUnitLogger.cs @@ -35,6 +35,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 +64,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 +101,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 +130,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 . /// From ed3222c31e0970b533c81b528e0a3026e1eecaee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20St=C3=BChmer?= Date: Thu, 23 May 2024 15:43:48 +0200 Subject: [PATCH 2/2] fix(style): Removed unused using --- src/NetEvolve.Logging.XUnit/XUnitLogger.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/NetEvolve.Logging.XUnit/XUnitLogger.cs b/src/NetEvolve.Logging.XUnit/XUnitLogger.cs index 2ba7881..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;