-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change logs to use LoggerMessage for higher performance and better management in a single file.
- Loading branch information
1 parent
47259f0
commit 1e8a091
Showing
18 changed files
with
594 additions
and
392 deletions.
There are no files selected for viewing
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
34 changes: 34 additions & 0 deletions
34
src/Tingle.EventBus.Transports.Amazon.Kinesis/ILoggerExtensions.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,34 @@ | ||
using Tingle.EventBus; | ||
|
||
namespace Microsoft.Extensions.Logging; | ||
|
||
/// <summary> | ||
/// Extensions on <see cref="ILogger"/> for the EventBus | ||
/// </summary> | ||
internal static partial class ILoggerExtensions | ||
{ | ||
[LoggerMessage(100, LogLevel.Information, "Sending {EventId} to '{StreamName}'. Scheduled: {Scheduled}.")] | ||
public static partial void SendingToStream(this ILogger logger, string? eventId, string streamName, DateTimeOffset? scheduled); | ||
|
||
[LoggerMessage(101, LogLevel.Information, "Sending {EventsCount} messages to '{StreamName}'. Scheduled: {Scheduled}. Events:\r\n- {EventIds}")] | ||
private static partial void SendingEventsToStream(this ILogger logger, int eventsCount, string streamName, DateTimeOffset? scheduled, string eventIds); | ||
|
||
public static void SendingEventsToStream(this ILogger logger, IList<string?> eventIds, string streamName, DateTimeOffset? scheduled) | ||
{ | ||
if (!logger.IsEnabled(LogLevel.Information)) return; | ||
logger.SendingEventsToStream(eventsCount: eventIds.Count, | ||
streamName: streamName, | ||
scheduled: scheduled, | ||
eventIds: string.Join("\r\n- ", eventIds)); | ||
} | ||
|
||
public static void SendingEventsToStream<T>(this ILogger logger, IList<EventContext<T>> events, string entityPath, DateTimeOffset? scheduled = null) | ||
where T : class | ||
{ | ||
if (!logger.IsEnabled(LogLevel.Information)) return; | ||
logger.SendingEventsToStream(events.Select(e => e.Id).ToList(), entityPath, scheduled); | ||
} | ||
|
||
[LoggerMessage(102, LogLevel.Warning, "Amazon Kinesis does not support delay or scheduled publish.")] | ||
public static partial void SchedulingNotSupported(this ILogger logger); | ||
} |
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
31 changes: 31 additions & 0 deletions
31
src/Tingle.EventBus.Transports.Amazon.Sqs/ILoggerExtensions.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,31 @@ | ||
namespace Microsoft.Extensions.Logging; | ||
|
||
/// <summary> | ||
/// Extensions on <see cref="ILogger"/> for the EventBus | ||
/// </summary> | ||
internal static partial class ILoggerExtensions | ||
{ | ||
[LoggerMessage(100, LogLevel.Information, "Sending {EventId} to '{TopicArn}'. Scheduled: {Scheduled}.")] | ||
public static partial void SendingToTopic(this ILogger logger, string? eventId, string topicArn, DateTimeOffset? scheduled); | ||
|
||
[LoggerMessage(101, LogLevel.Information, "Received message: '{MessageId}' containing Event '{EventId}' from '{QueueUrl}'")] | ||
public static partial void ReceivedMessage(this ILogger logger, string messageId, string? eventId, string queueUrl); | ||
|
||
[LoggerMessage(102, LogLevel.Warning, "Amazon SNS does not support delay or scheduled publish.")] | ||
public static partial void SchedulingNotSupported(this ILogger logger); | ||
|
||
[LoggerMessage(103, LogLevel.Warning, "Amazon SNS does not support batching. The events will be looped through one by one.")] | ||
public static partial void BatchingNotSupported(this ILogger logger); | ||
|
||
[LoggerMessage(104, LogLevel.Trace, "No messages on '{QueueUrl}', delaying check for {Delay}.")] | ||
public static partial void NoMessages(this ILogger logger, string queueUrl, TimeSpan delay); | ||
|
||
[LoggerMessage(105, LogLevel.Debug, "Received {MessagesCount} messages on '{QueueUrl}'")] | ||
public static partial void ReceivedMessages(this ILogger logger, int messagesCount, string queueUrl); | ||
|
||
[LoggerMessage(106, LogLevel.Debug, "Processing '{MessageId}' from '{QueueUrl}'")] | ||
public static partial void ProcessingMessage(this ILogger logger, string messageId, string queueUrl); | ||
|
||
[LoggerMessage(107, LogLevel.Trace, "Deleting '{MessageId}' from '{QueueUrl}'")] | ||
public static partial void DeletingMessage(this ILogger logger, string messageId, string queueUrl); | ||
} |
Oops, something went wrong.