2021-04-23 20:11:49 +00:00
|
|
|
using System;
|
|
|
|
using SimpleLogger;
|
|
|
|
using Xunit.Abstractions;
|
|
|
|
|
2021-05-21 18:32:25 +00:00
|
|
|
namespace MultiShop.Shop.BanggoodModule
|
2021-04-23 20:11:49 +00:00
|
|
|
{
|
|
|
|
public class XUnitLogger : ILogReceiver
|
|
|
|
{
|
2021-05-09 06:49:37 +00:00
|
|
|
public LogLevel Level => LogLevel.Debug;
|
2021-04-23 20:11:49 +00:00
|
|
|
|
|
|
|
public string Identifier => GetType().Name;
|
|
|
|
|
|
|
|
private ITestOutputHelper outputHelper;
|
|
|
|
|
|
|
|
public XUnitLogger(ITestOutputHelper output)
|
|
|
|
{
|
|
|
|
this.outputHelper = output;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Flush()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public void LogMessage(string message, DateTime time, LogLevel level)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
outputHelper.WriteLine($"[{time.ToShortTimeString()}][{level.ToString()}]: {message}");
|
|
|
|
}
|
|
|
|
catch (InvalidOperationException) { };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|