Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

Commit

Permalink
Merge pull request #15 from Authenticom/develop
Browse files Browse the repository at this point in the history
Resolves issue with Event extension methods where no event is sent when a log event message is not specified
  • Loading branch information
sirkirby authored Dec 19, 2017
2 parents 19011e5 + cb459bb commit 7adab8d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
9 changes: 5 additions & 4 deletions src/Serilog.Sinks.EventGrid/LoggerEventGridExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ public static class LoggerEventGridExtensions
/// <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 Event(this ILogger logger, string eventType, string subject, string messageTemplate, params object[] props)
public static void Event(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);

logger.Information(messageTemplate, props);
}

/// <summary>Log to Event Grid with custom subject and message template w/ custom args</summary>
Expand Down Expand Up @@ -44,7 +45,7 @@ public static void EventSubject(this ILogger logger, string subject, string mess
/// <param name="props">The values references in the templace to be added to the EventGrid Grid data payload</param>
public static void EventType(this ILogger logger, string eventType, string messageTemplate, params object[] props)
{
logger.Event(eventType, null, messageTemplate, props);
logger.Event(eventType, null, messageTemplate, props);
}

/// <summary>Log to Event Grid with custom type and message template</summary>
Expand Down
12 changes: 6 additions & 6 deletions src/Serilog.Sinks.EventGrid/Serilog.Sinks.EventGrid.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@
<RepositoryUrl>https://github.com/Authenticom/serilog-sinks-eventgrid</RepositoryUrl>
<PackageTags>serilog sink events eventgrid azure</PackageTags>
<Copyright>Copyright © Chris Kirby 2017</Copyright>
<Version>1.1.0</Version>
<Version>1.1.1</Version>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net461'">
<PackageReference Include="Microsoft.Net.Http">
<Version>2.2.29</Version>
</PackageReference>
</ItemGroup>

<ItemGroup>
<PackageReference Include="newtonsoft.json" Version="10.0.3" />
<PackageReference Include="serilog" Version="2.5.0" />
<PackageReference Include="serilog.sinks.periodicbatching" Version="2.1.1" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.4.0" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="Serilog" Version="2.6.0" />
<PackageReference Include="Serilog.Sinks.PeriodicBatching" Version="2.1.1" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.4.1" />
</ItemGroup>

</Project>
10 changes: 5 additions & 5 deletions src/Serilog.Sinks.EventGrid/Sinks/EventGrid/EventGridSink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ public class EventGridSink : PeriodicBatchingSink
public const int DefaultBatchPostingLimit = 10;
public static readonly TimeSpan DefaultPeriod = TimeSpan.FromSeconds(5);

public EventGridSink(IFormatProvider formatProvider,
string key,
Uri topicUri,
public EventGridSink(IFormatProvider formatProvider,
string key,
Uri topicUri,
string customEventSubject,
string customEventType,
CustomEventRequestAuth customEventRequestAuth,
string customEventType,
CustomEventRequestAuth customEventRequestAuth,
string customSubjectPropertyName,
string customTypePropertyName,
int batchSizeLimit,
Expand Down

0 comments on commit 7adab8d

Please sign in to comment.