-
Notifications
You must be signed in to change notification settings - Fork 4.8k
/
NullLogger.cs
42 lines (36 loc) · 1.16 KB
/
NullLogger.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
// 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 : ILogger
{
/// <summary>
/// Returns the shared instance of <see cref="NullLogger"/>.
/// </summary>
public static NullLogger Instance { get; } = new NullLogger();
/// <summary>
/// Initializes a new instance of the <see cref="NullLogger"/> class.
/// </summary>
private NullLogger()
{
}
/// <inheritdoc />
public IDisposable BeginScope<TState>(TState state) where TState : notnull
{
return NullScope.Instance;
}
/// <inheritdoc />
public bool IsEnabled(LogLevel logLevel)
{
return false;
}
/// <inheritdoc />
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func<TState, Exception?, string> formatter)
{
}
}
}