Created
April 22, 2020 02:08
-
-
Save gocha/abf91133e964bbc104cd75b68397cade to your computer and use it in GitHub Desktop.
指定された ILogger に出力を委譲するだけの不毛な ILogger<TCategoryName> 実装
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.Extensions.Logging; | |
using System; | |
namespace Stupid | |
{ | |
public class DelegateLogger<TCategoryName> : ILogger<TCategoryName> | |
{ | |
private readonly ILogger _logger; | |
public DelegateLogger(ILogger logger) { _logger = logger; } | |
public IDisposable BeginScope<TState>(TState state) => _logger.BeginScope(state); | |
public bool IsEnabled(LogLevel logLevel) => _logger.IsEnabled(logLevel); | |
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, | |
Exception exception, Func<TState, Exception, string> formatter) => | |
_logger.Log(logLevel, eventId, state, exception, formatter); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment