-
-
Notifications
You must be signed in to change notification settings - Fork 198
/
ConsoleLogger.cs
41 lines (34 loc) · 1021 Bytes
/
ConsoleLogger.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using Microsoft.Extensions.Logging;
using System;
using Xunit.Abstractions;
namespace YesSql.Tests
{
public class ConsoleLogger : ILogger
{
private readonly ITestOutputHelper _output;
public ConsoleLogger(ITestOutputHelper output)
{
_output = output;
}
public IDisposable BeginScope<TState>(TState state)
{
return new FakeScope();
}
public bool IsEnabled(LogLevel logLevel)
{
return IsLevelEnabled(logLevel);
}
public bool IsLevelEnabled(LogLevel logLevel)
{
return true;
}
public void Log(LogLevel logLevel, string log)
{
_output.WriteLine(logLevel.ToString().ToUpper() + ": " + log);
}
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
{
Log(logLevel, formatter(state, exception));
}
}
}