-
-
Notifications
You must be signed in to change notification settings - Fork 14
Closed
Labels
feature-requestA request for new functionalityA request for new functionality
Description
Is your feature request related to a problem?
In unit tests, there are times when I need an ILogger<T> without the overhead of dependency injection, ILoggerFactory, or a LoggerProvider. This can simplify test setup and make the tests more straightforward.
Describe the solution you'd like
I would like to have a XUnitLogger<T> class that implements the ILogger<T> interface. This logger should be easy to instantiate directly in unit tests without requiring dependency injection, ILoggerFactory, or a provider. It should integrate with xUnit's output capturing mechanisms to display log messages in the test results and support various log levels.
Describe alternatives you've considered
I haven't considered any alternatives that would be as simple and lightweight as this.
Simple implementation
private sealed class XUnitLogger<T> : XUnitLogger, ILogger<T>
{
public XUnitLogger(IMessageSink messageSink, XUnitLoggerOptions options) : base(typeof(T).FullName, messageSink, options)
{
}
public XUnitLogger(IMessageSinkAccessor accessor, XUnitLoggerOptions options) : base(typeof(T).FullName, accessor, options)
{
}
public XUnitLogger(ITestOutputHelper outputHelper, XUnitLoggerOptions options) : base(typeof(T).FullName, outputHelper, options)
{
}
public XUnitLogger(ITestOutputHelperAccessor accessor, XUnitLoggerOptions options) : base(typeof(T).FullName, accessor, options)
{
}
}Metadata
Metadata
Assignees
Labels
feature-requestA request for new functionalityA request for new functionality