This repository has been archived by the owner on Sep 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from Authenticom/develop
added log event message to the event data payload
- Loading branch information
Showing
4 changed files
with
50 additions
and
1 deletion.
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
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 Serilog.Sinks.EventGrid | ||
{ | ||
public static class LoggerEventGridExtensions | ||
{ | ||
/// <summary>Information log event helper for EventGrid sink</summary> | ||
/// <param name="logger">The Serilog ILogger</param> | ||
/// <param name="eventType">The event type sent to EventGrid Grid</param> | ||
/// <param name="subject">The event subject sent to EventGrid Grid</param> | ||
/// <param name="messageTemplate">The Serilog logger message template</param> | ||
/// <param name="props">The values references in the templace to be added to the EventGrid Grid data payload</param> | ||
public static void EventGrid(this ILogger logger, string eventType, string subject, string messageTemplate, params object[] props) | ||
{ | ||
if (!string.IsNullOrEmpty(subject)) | ||
logger = logger.ForContext("EventSubject", subject); | ||
if (!string.IsNullOrEmpty(eventType)) | ||
logger = logger.ForContext("EventType", eventType); | ||
if (!string.IsNullOrEmpty(messageTemplate)) | ||
logger.Information(messageTemplate, props); | ||
} | ||
|
||
public static void EventGrid(this ILogger logger, string eventType, string messageTemplate, params object[] props) | ||
{ | ||
logger.EventGrid(eventType, null, messageTemplate, props); | ||
} | ||
|
||
public static void EventGrid(this ILogger logger, string eventType, string messageTemplate) | ||
{ | ||
logger.EventGrid(eventType, null, messageTemplate, null); | ||
} | ||
} | ||
} |
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
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