-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTestLogger.cs
More file actions
28 lines (23 loc) · 841 Bytes
/
TestLogger.cs
File metadata and controls
28 lines (23 loc) · 841 Bytes
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
namespace OneBitSoftware.Utilities.OperationResultTests
{
public class TestLogger : ILogger
{
private readonly List<string> _logMessages = new List<string>();
public IReadOnlyList<string> LogMessages => _logMessages.AsReadOnly();
public IDisposable BeginScope<TState>(TState state) => null;
public bool IsEnabled(LogLevel logLevel) => true;
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
{
if (formatter != null)
{
_logMessages.Add(formatter(state, exception));
}
}
}
}