35 lines
1010 B
C#
35 lines
1010 B
C#
|
using Chatbot.Api.Application.Commands;
|
|||
|
using Chatbot.Api.Application.Events;
|
|||
|
using MediatR;
|
|||
|
using Microsoft.Extensions.Logging;
|
|||
|
using System;
|
|||
|
using System.Threading;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
namespace Chatbot.Api.Application.CommandHandlers
|
|||
|
{
|
|||
|
public class TestLoggerHandler : IRequestHandler<TestLogger, LoggerTested>
|
|||
|
{
|
|||
|
private readonly ILogger<TestLoggerHandler> _logger;
|
|||
|
|
|||
|
public TestLoggerHandler(ILogger<TestLoggerHandler> logger)
|
|||
|
{
|
|||
|
_logger = logger;
|
|||
|
}
|
|||
|
|
|||
|
public async Task<LoggerTested> Handle(TestLogger request, CancellationToken cancellationToken)
|
|||
|
{
|
|||
|
_logger.LogDebug(TextToLog);
|
|||
|
_logger.LogInformation(TextToLog);
|
|||
|
_logger.LogWarning(TextToLog);
|
|||
|
_logger.LogError(TextToLog);
|
|||
|
_logger.LogCritical(TextToLog);
|
|||
|
|
|||
|
await Task.Delay(1);
|
|||
|
return new LoggerTested();
|
|||
|
}
|
|||
|
|
|||
|
private string TextToLog => $"Logger test - {DateTime.Now}";
|
|||
|
}
|
|||
|
}
|