mirror of
https://github.com/bitwarden/server
synced 2025-12-06 00:03:34 +00:00
* Initial v3 Migration * Migrate tests and debug duplicate ids * Debug duplicate ids * Support seeding * remove seeder * Upgrade to latest XUnit.v3 version * Remove Theory changes for now * Remove Theory change from DeviceRepositoryTests * Remove cancellation token additions
48 lines
1.1 KiB
C#
48 lines
1.1 KiB
C#
using Microsoft.Extensions.Logging;
|
|
using Xunit;
|
|
|
|
namespace Bit.Infrastructure.IntegrationTest;
|
|
|
|
public sealed class XUnitLoggerProvider : ILoggerProvider
|
|
{
|
|
public ILogger CreateLogger(string categoryName)
|
|
{
|
|
return new XUnitLogger(categoryName);
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
|
|
}
|
|
|
|
private class XUnitLogger : ILogger
|
|
{
|
|
private readonly string _categoryName;
|
|
|
|
public XUnitLogger(string categoryName)
|
|
{
|
|
_categoryName = categoryName;
|
|
}
|
|
|
|
public IDisposable? BeginScope<TState>(TState state) where TState : notnull
|
|
{
|
|
return null;
|
|
}
|
|
|
|
public bool IsEnabled(LogLevel logLevel)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func<TState, Exception?, string> formatter)
|
|
{
|
|
if (TestContext.Current?.TestOutputHelper is not ITestOutputHelper testOutputHelper)
|
|
{
|
|
return;
|
|
}
|
|
|
|
testOutputHelper.WriteLine($"[{_categoryName}] {formatter(state, exception)}");
|
|
}
|
|
}
|
|
}
|