forked from dotnet/yarp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestLogger.cs
More file actions
35 lines (28 loc) · 976 Bytes
/
TestLogger.cs
File metadata and controls
35 lines (28 loc) · 976 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
29
30
31
32
33
34
35
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using Microsoft.Extensions.Logging;
using Xunit;
namespace Yarp.Kubernetes.Tests.Utils;
public class TestLogger<T> : ILogger<T>
{
private readonly ITestOutputHelper _output;
private readonly LogLevel _minLogLevel;
public TestLogger(ITestOutputHelper output, LogLevel minLogLevel = LogLevel.Debug)
{
_output = output;
_minLogLevel = minLogLevel;
}
public IDisposable BeginScope<TState>(TState state)
{
return null;
}
public bool IsEnabled(LogLevel logLevel)
{
return logLevel != LogLevel.None && logLevel >= _minLogLevel;
}
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
{
_output.WriteLine(formatter.Invoke(state, exception));
}
}