Clean Architecture Demo
Loading...
Searching...
No Matches
LoggingEmailService.cs
Go to the documentation of this file.
1using Microsoft.Extensions.Logging;
3
5
21{
22 private static readonly Action<ILogger, Guid, Exception?> LogTaskCompletedEmail =
23 LoggerMessage.Define<Guid>(
24 LogLevel.Information,
25 new EventId(2001, nameof(SendTaskCompletedNotificationAsync)),
26 "Email sent: task {TaskId} completed");
27
28 private readonly ILogger<LoggingEmailService> _logger;
29
30 public LoggingEmailService(ILogger<LoggingEmailService> logger)
31 {
32 _logger = logger;
33 }
34
35 public Task SendTaskCompletedNotificationAsync(Guid taskId, CancellationToken cancellationToken = default)
36 {
37 LogTaskCompletedEmail(_logger, taskId, null);
38 return Task.CompletedTask;
39 }
40}
LoggingEmailService(ILogger< LoggingEmailService > logger)
Task SendTaskCompletedNotificationAsync(Guid taskId, CancellationToken cancellationToken=default)
IEmailService es la abstracción para envío de notificaciones por correo electrónico.