-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#72 added retry to arrival and departure queues
- Loading branch information
Showing
3 changed files
with
79 additions
and
39 deletions.
There are no files selected for viewing
18 changes: 11 additions & 7 deletions
18
source/MailKitSimplified.Receiver/Extensions/EmailReceiverExtensions.cs
This file contains 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
25 changes: 25 additions & 0 deletions
25
source/MailKitSimplified.Receiver/Extensions/LoggerExtensions.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace MailKitSimplified.Receiver.Extensions | ||
{ | ||
/// <summary> | ||
/// <see href="https://learn.microsoft.com/en-us/dotnet/core/extensions/high-performance-logging"/> | ||
/// </summary> | ||
[ExcludeFromCodeCoverage] | ||
public static class LoggerExtensions | ||
{ | ||
public static void Serialized<T>(this ILogger logger, T obj, LogLevel logLevel = LogLevel.Information) where T : class => | ||
logger.Log(logLevel, "\"{Name}\": {JsonSerializedObject}", typeof(T).Name, obj.ToSerializedString()); | ||
|
||
internal static Action<ILogger, Exception> LogAction<T>(string message, LogLevel logLevel, int id) => | ||
LoggerMessage.Define(logLevel, new EventId(id, name: typeof(T).Name), message); | ||
|
||
public static void Log<T>(this ILogger logger, string message, LogLevel logLevel = LogLevel.Information, int id = 0) => | ||
LogAction<T>(message, logLevel, id)(logger, null); | ||
|
||
public static void Log<T>(this ILogger logger, Exception ex, string message, LogLevel logLevel = LogLevel.Error, int id = 1) => | ||
LogAction<T>(message, logLevel, id)(logger, ex); | ||
} | ||
} |
This file contains 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