Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MartinCostello.Logging.XUnit" Version="0.7.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.5.1" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
Expand All @@ -17,9 +18,6 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Serilog.Extensions.Logging" Version="10.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.1.1" />
<PackageReference Include="Serilog.Sinks.XUnit" Version="3.0.19" />
</ItemGroup>

<ItemGroup>
Expand Down
25 changes: 13 additions & 12 deletions test/SIPSorcery.VP8.TestVectors/TestLogger.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Filename: TestLogger.cs
//
// Description: Helper class for test logging.
Expand All @@ -14,23 +14,24 @@
//-----------------------------------------------------------------------------

using Microsoft.Extensions.Logging;
using Serilog;
using Serilog.Extensions.Logging;
using MartinCostello.Logging.XUnit;

namespace Vpx.Net.TestVectors
{
public class TestLogger
{
public static ILoggerFactory GetLogger(Xunit.Abstractions.ITestOutputHelper output)
{
string template = "{Timestamp:HH:mm:ss.ffff} [{Level}] {Scope} {Message}{NewLine}{Exception}";
var serilog = new LoggerConfiguration()
.MinimumLevel.Is(Serilog.Events.LogEventLevel.Debug)
.Enrich.WithProperty("ThreadId", System.Threading.Thread.CurrentThread.ManagedThreadId)
.WriteTo.TestOutput(output, outputTemplate: template)
.WriteTo.Console(outputTemplate: template)
.CreateLogger();
return new SerilogLoggerFactory(serilog);
var options = new XUnitLoggerOptions
{
Filter = (category, level) => level >= LogLevel.Debug
};
var loggerProvider = new XUnitLoggerProvider(output, options);

return LoggerFactory.Create(builder =>
{
builder.AddProvider(loggerProvider);
});
}
}
}
}
4 changes: 1 addition & 3 deletions test/SIPSorcery.VP8.UnitTest/SIPSorcery.VP8.UnitTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MartinCostello.Logging.XUnit" Version="0.7.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.5.1" />
<PackageReference Include="System.Drawing.Common" Version="10.0.7" />
<PackageReference Include="xunit" Version="2.9.3" />
Expand All @@ -18,9 +19,6 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Serilog.Extensions.Logging" Version="10.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.1.1" />
<PackageReference Include="Serilog.Sinks.XUnit" Version="3.0.19" />
</ItemGroup>

<ItemGroup>
Expand Down
26 changes: 12 additions & 14 deletions test/SIPSorcery.VP8.UnitTest/TestLogger.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
using Microsoft.Extensions.Logging;
using Serilog;
using Serilog.Extensions.Logging;
using MartinCostello.Logging.XUnit;
using Microsoft.Extensions.Logging;

namespace Vpx.Net.UnitTest
{
public class TestLogger
{
public static ILoggerFactory GetLogger(Xunit.Abstractions.ITestOutputHelper output)
{
string template = "{Timestamp:HH:mm:ss.ffff} [{Level}] {Scope} {Message}{NewLine}{Exception}";
//var loggerFactory = new Microsoft.Extensions.Logging.LoggerFactory();
var serilog = new LoggerConfiguration()
.MinimumLevel.Is(Serilog.Events.LogEventLevel.Debug)
.Enrich.WithProperty("ThreadId", System.Threading.Thread.CurrentThread.ManagedThreadId)
.WriteTo.TestOutput(output, outputTemplate: template)
.WriteTo.Console(outputTemplate: template)
.CreateLogger();
//SIPSorcery.LogFactory.Set(new SerilogLoggerFactory(serilog));
//return new SerilogLoggerProvider(serilog).CreateLogger("unit");
return new SerilogLoggerFactory(serilog);
var options = new XUnitLoggerOptions
{
Filter = (category, level) => level >= LogLevel.Debug
};
var loggerProvider = new XUnitLoggerProvider(output, options);

return LoggerFactory.Create(builder =>
{
builder.AddProvider(loggerProvider);
});
}
}
}
12 changes: 6 additions & 6 deletions test/SIPSorceryMedia.Abstractions.UnitTest/PixelConverterTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Filename: PixelConverterTest.cs
//
// Description: Unit tests for the pixel conversion methods.
Expand Down Expand Up @@ -110,7 +110,7 @@ public unsafe void ConvertKnownI420ToBGRTest()
public unsafe void ConvertKnownNV12ToBGRTest()
{
logger.LogDebug("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);
logger.BeginScope(System.Reflection.MethodBase.GetCurrentMethod().Name);
logger.BeginScope(TestHelper.GetCurrentMethodName());

int width = 640;
int height = 480;
Expand Down Expand Up @@ -285,7 +285,7 @@ public unsafe void Roundtrip_Bitmap_719x405()
public unsafe void ConvertNV12ToI420Test()
{
logger.LogDebug("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);
logger.BeginScope(System.Reflection.MethodBase.GetCurrentMethod().Name);
logger.BeginScope(TestHelper.GetCurrentMethodName());

int width = 640;
int height = 480;
Expand Down Expand Up @@ -316,7 +316,7 @@ public unsafe void ConvertNV12ToI420Test()
public unsafe void ConvertI420ToNV12Test()
{
logger.LogDebug("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);
logger.BeginScope(System.Reflection.MethodBase.GetCurrentMethod().Name);
logger.BeginScope(TestHelper.GetCurrentMethodName());

int width = 640;
int height = 480;
Expand Down Expand Up @@ -347,7 +347,7 @@ public unsafe void ConvertI420ToNV12Test()
public void RoundtripNV12ToI420Test()
{
logger.LogDebug("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);
logger.BeginScope(System.Reflection.MethodBase.GetCurrentMethod().Name);
logger.BeginScope(TestHelper.GetCurrentMethodName());

int width = 640;
int height = 480;
Expand All @@ -372,7 +372,7 @@ public void RoundtripNV12ToI420Test()
public void RoundtripI420ToNV12Test()
{
logger.LogDebug("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);
logger.BeginScope(System.Reflection.MethodBase.GetCurrentMethod().Name);
logger.BeginScope(TestHelper.GetCurrentMethodName());

int width = 640;
int height = 480;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.7" />
<PackageReference Include="MartinCostello.Logging.XUnit" Version="0.7.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.5.1" />
<PackageReference Include="System.Drawing.Common" Version="10.0.7" />
<PackageReference Include="xunit" Version="2.9.3" />
Expand All @@ -19,9 +19,6 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Serilog.Extensions.Logging" Version="10.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.1.1" />
<PackageReference Include="Serilog.Sinks.XUnit" Version="3.0.19" />
</ItemGroup>

<ItemGroup>
Expand Down
9 changes: 9 additions & 0 deletions test/SIPSorceryMedia.Abstractions.UnitTest/TestHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Runtime.CompilerServices;

namespace SIPSorceryMedia.Abstractions.UnitTest
{
public static class TestHelper
{
public static string GetCurrentMethodName([CallerMemberName] string methodName = default) => methodName;
}
}
21 changes: 11 additions & 10 deletions test/SIPSorceryMedia.Abstractions.UnitTest/TestLogger.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
using Microsoft.Extensions.Logging;
using Serilog;
using Serilog.Extensions.Logging;
using MartinCostello.Logging.XUnit;

namespace SIPSorceryMedia.Abstractions.UnitTest
{
public class TestLogger
{
public static ILoggerFactory GetLogger(Xunit.Abstractions.ITestOutputHelper output)
{
string template = "{Timestamp:HH:mm:ss.ffff} [{Level}] {Scope} {Message}{NewLine}{Exception}";
var serilog = new LoggerConfiguration()
.MinimumLevel.Is(Serilog.Events.LogEventLevel.Debug)
.Enrich.WithProperty("ThreadId", System.Threading.Thread.CurrentThread.ManagedThreadId)
.WriteTo.TestOutput(output, outputTemplate: template)
.WriteTo.Console(outputTemplate: template)
.CreateLogger();
return new SerilogLoggerFactory(serilog);
var options = new XUnitLoggerOptions
{
Filter = (category, level) => level >= LogLevel.Debug
};
var loggerProvider = new XUnitLoggerProvider(output, options);

return LoggerFactory.Create(builder =>
{
builder.AddProvider(loggerProvider);
});
}
}
}
Loading
Loading