From 33ab42332f9e6837de55f49fa478af3631109a8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20St=C3=BChmer?= Date: Thu, 23 May 2024 15:57:04 +0200 Subject: [PATCH] chore: Added missing `CreateLogger` overloads (#18) * chore: Added missing `CreateLogger` overloads * fix(style): Removed unused using --- src/NetEvolve.Logging.XUnit/XUnitLogger.cs | 60 +++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) 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 . ///