feat: 在前端显示编译过程中的日志 (#67)

Reviewed-on: PostGuard/Canon#67
This commit is contained in:
2024-04-29 23:55:36 +08:00
parent 4d325569fa
commit 911c813996
15 changed files with 243 additions and 204 deletions

View File

@@ -1,24 +1,16 @@
using Microsoft.Extensions.Logging;
using Canon.Core.Abstractions;
using Microsoft.Extensions.Logging;
using Xunit.Abstractions;
namespace Canon.Tests.Utils;
public class TestLogger<T>(ITestOutputHelper testOutputHelper) : ILogger<T>, IDisposable
public class TestLogger(ITestOutputHelper testOutputHelper) : ICompilerLogger
{
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception? exception,
Func<TState, Exception?, string> formatter)
{
testOutputHelper.WriteLine("{0}: {1}", logLevel, formatter(state, exception));
testOutputHelper.WriteLine($"{logLevel}: {formatter(state, exception)}");
}
public bool IsEnabled(LogLevel logLevel) => false;
public void Dispose()
{
}
public IDisposable BeginScope<TState>(TState state) where TState : notnull
{
return this;
}
public string Build() => string.Empty;
}