props/Props-Modules/test/Props.Shop/BanggoodModule.Tests/XUnitLogger.cs

33 lines
768 B
C#
Raw Normal View History

using System;
using SimpleLogger;
using Xunit.Abstractions;
namespace Props.Shop.BanggoodModule
{
public class XUnitLogger : ILogReceiver
{
2021-05-09 06:49:37 +00:00
public LogLevel Level => LogLevel.Debug;
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) { };
}
}
}