-
Notifications
You must be signed in to change notification settings - Fork 4.7k
/
NullLoggerT.cs
44 lines (39 loc) · 1.24 KB
/
NullLoggerT.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
42
43
44
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
namespace Microsoft.Extensions.Logging.Abstractions
{
/// <summary>
/// Minimalistic logger that does nothing.
/// </summary>
public class NullLogger<T> : ILogger<T>
{
/// <summary>
/// Returns an instance of <see cref="NullLogger{T}"/>.
/// </summary>
/// <returns>An instance of <see cref="NullLogger{T}"/>.</returns>
public static readonly NullLogger<T> Instance = new NullLogger<T>();
/// <inheritdoc />
public IDisposable BeginScope<TState>(TState state) where TState : notnull
{
return NullScope.Instance;
}
/// <inheritdoc />
/// <remarks>
/// This method ignores the parameters and does nothing.
/// </remarks>
public void Log<TState>(
LogLevel logLevel,
EventId eventId,
TState state,
Exception? exception,
Func<TState, Exception?, string> formatter)
{
}
/// <inheritdoc />
public bool IsEnabled(LogLevel logLevel)
{
return false;
}
}
}