aspnetcore/src/Microsoft.Net.Http.Server/NullLogger.cs

38 lines
1.0 KiB
C#

// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.Extensions.Logging;
namespace Microsoft.Net.Http.Server
{
internal class NullLogger : ILogger
{
public static readonly NullLogger Instance = new NullLogger();
public IDisposable BeginScope<TState>(TState state)
{
return NullDisposable.Instance;
}
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
{
}
public bool IsEnabled(LogLevel logLevel)
{
return false;
}
private class NullDisposable : IDisposable
{
public static readonly NullDisposable Instance = new NullDisposable();
public void Dispose()
{
// intentionally does nothing
}
}
}
}