Skip to content

Commit

Permalink
Merge pull request #29 from serilog/dev
Browse files Browse the repository at this point in the history
6.0.0 Release
  • Loading branch information
nblumhardt authored Feb 8, 2022
2 parents 6d82b47 + 5c29219 commit f022131
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 71 deletions.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ artifacts:
deploy:
- provider: NuGet
api_key:
secure: M3xezaJaXj9AKyEhceQI9XRCP7/tG1YLOGM6x9tBAVuhE45IP9leFegUDtu632FD
secure: pvGk80Hl+hnqiV0ucxBI2ZkYUlR6l7TrGZek37OCFh9Fro4BOhEBI2+UMkDwtgjt
skip_symbols: true
on:
branch: /^(master|dev)$/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

using System;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Azure.EventHubs;
using Azure.Messaging.EventHubs.Producer;
using Serilog.Configuration;
using Serilog.Core;
using Serilog.Events;
Expand Down Expand Up @@ -45,7 +45,7 @@ public static class AuditLoggerConfigurationAzureEventHubExtensions
/// <exception cref="ArgumentNullException">A required parameter is null.</exception>
public static LoggerConfiguration AzureEventHub(
this LoggerAuditSinkConfiguration loggerConfiguration,
EventHubClient eventHubClient,
EventHubProducerClient eventHubClient,
string outputTemplate = DefaultOutputTemplate,
IFormatProvider formatProvider = null,
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum
Expand Down Expand Up @@ -75,7 +75,7 @@ public static LoggerConfiguration AzureEventHub(
public static LoggerConfiguration AzureEventHub(
this LoggerAuditSinkConfiguration loggerConfiguration,
ITextFormatter formatter,
EventHubClient eventHubClient,
EventHubProducerClient eventHubClient,
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum)
{
if (loggerConfiguration == null)
Expand Down Expand Up @@ -115,12 +115,7 @@ public static LoggerConfiguration AzureEventHub(
if (string.IsNullOrWhiteSpace(eventHubName))
throw new ArgumentNullException("eventHubName");

var connectionstringBuilder = new EventHubsConnectionStringBuilder(connectionString)
{
EntityPath = eventHubName
};

var client = EventHubClient.CreateFromConnectionString(connectionstringBuilder.ToString());
var client = new EventHubProducerClient(connectionString, eventHubName);

return AzureEventHub(loggerConfiguration, client, outputTemplate, formatProvider, restrictedToMinimumLevel);
}
Expand Down Expand Up @@ -150,11 +145,7 @@ public static LoggerConfiguration AzureEventHub(
if (string.IsNullOrWhiteSpace(eventHubName))
throw new ArgumentNullException("eventHubName");

var connectionStringBuilder = new EventHubsConnectionStringBuilder(connectionString)
{
EntityPath = eventHubName
};
var client = EventHubClient.CreateFromConnectionString(connectionStringBuilder.ToString());
var client = new EventHubProducerClient(connectionString, eventHubName);
return AzureEventHub(loggerConfiguration, formatter, client, restrictedToMinimumLevel);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

using System;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Azure.EventHubs;
using Azure.Messaging.EventHubs.Producer;
using Serilog.Configuration;
using Serilog.Core;
using Serilog.Events;
Expand Down Expand Up @@ -59,7 +59,7 @@ public static class LoggerConfigurationAzureEventHubExtensions
/// <exception cref="ArgumentNullException">A required parameter is null.</exception>
public static LoggerConfiguration AzureEventHub(
this LoggerSinkConfiguration loggerConfiguration,
EventHubClient eventHubClient,
EventHubProducerClient eventHubClient,
string outputTemplate = DefaultOutputTemplate,
IFormatProvider formatProvider = null,
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
Expand Down Expand Up @@ -96,7 +96,7 @@ public static LoggerConfiguration AzureEventHub(
public static LoggerConfiguration AzureEventHub(
this LoggerSinkConfiguration loggerConfiguration,
ITextFormatter formatter,
EventHubClient eventHubClient,
EventHubProducerClient eventHubClient,
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
bool writeInBatches = false,
TimeSpan? period = null,
Expand Down Expand Up @@ -153,12 +153,7 @@ public static LoggerConfiguration AzureEventHub(
if (string.IsNullOrWhiteSpace(eventHubName))
throw new ArgumentNullException("eventHubName");

var connectionstringBuilder = new EventHubsConnectionStringBuilder(connectionString)
{
EntityPath = eventHubName
};

var client = EventHubClient.CreateFromConnectionString(connectionstringBuilder.ToString());
var client = new EventHubProducerClient(connectionString, eventHubName);

return AzureEventHub(loggerConfiguration, client, outputTemplate, formatProvider, restrictedToMinimumLevel, writeInBatches, period, batchPostingLimit);
}
Expand Down Expand Up @@ -195,11 +190,7 @@ public static LoggerConfiguration AzureEventHub(
if (string.IsNullOrWhiteSpace(eventHubName))
throw new ArgumentNullException("eventHubName");

var connectionStringBuilder = new EventHubsConnectionStringBuilder(connectionString)
{
EntityPath = eventHubName
};
var client = EventHubClient.CreateFromConnectionString(connectionStringBuilder.ToString());
var client = new EventHubProducerClient(connectionString, eventHubName);

return AzureEventHub(loggerConfiguration, formatter, client, restrictedToMinimumLevel, writeInBatches, period, batchPostingLimit);
}
Expand Down
58 changes: 27 additions & 31 deletions src/Serilog.Sinks.AzureEventHub/Serilog.Sinks.AzureEventHub.csproj
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>Write Serilog events to Azure Event Hub</Description>
<VersionPrefix>5.0.0</VersionPrefix>
<Authors>Serilog Contributors</Authors>
<TargetFrameworks>netstandard2.0;net461;net451</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>Serilog.Sinks.AzureEventHub</AssemblyName>
<AssemblyOriginatorKeyFile>../../assets/Serilog.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
<PackageId>Serilog.Sinks.AzureEventHub</PackageId>
<PackageTags>serilog;;azure;eventhub</PackageTags>
<PackageIconUrl>http://serilog.net/images/serilog-sink-nuget.png</PackageIconUrl>
<PackageProjectUrl>http://serilog.net</PackageProjectUrl>
<PackageLicenseUrl>http://www.apache.org/licenses/LICENSE-2.0</PackageLicenseUrl>
<RepositoryUrl>https://github.com/serilog/serilog-sinks-azureeventhub</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<RootNamespace>Serilog</RootNamespace>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<!-- Don't reference the full NETStandard.Library -->
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.EventHubs" Version="1.0.3" />
<PackageReference Include="Serilog" Version="2.5.0" />
<PackageReference Include="Serilog.Sinks.PeriodicBatching" Version="2.1.1" />
</ItemGroup>

</Project>
<PropertyGroup>
<Description>Write Serilog events to Azure Event Hub</Description>
<VersionPrefix>6.0.0</VersionPrefix>
<Authors>Serilog Contributors</Authors>
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>Serilog.Sinks.AzureEventHub</AssemblyName>
<AssemblyOriginatorKeyFile>../../assets/Serilog.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
<PackageId>Serilog.Sinks.AzureEventHub</PackageId>
<PackageTags>serilog;azure;eventhub</PackageTags>
<PackageProjectUrl>http://serilog.net</PackageProjectUrl>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<RepositoryUrl>https://github.com/serilog/serilog-sinks-azureeventhub</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<RootNamespace>Serilog</RootNamespace>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<!-- <PackageReference Include="Microsoft.Azure.EventHubs" Version="4.*"/> -->
<PackageReference Include="Serilog" Version="2.5.0"/>
<PackageReference Include="Serilog.Sinks.PeriodicBatching" Version="2.1.1"/>
<PackageReference Include="Azure.Messaging.EventHubs" Version="5.4.1"/>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
<description>Serilog event sink that writes to Azure Event Hubs.</description>
<language>en-US</language>
<projectUrl>http://serilog.net</projectUrl>
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0</licenseUrl>
<iconUrl>http://serilog.net/images/serilog-sink-nuget.png</iconUrl>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageIconUrl>http://serilog.net/images/serilog-sink-nuget.png</PackageIconUrl>
<repository type="git" url="https://github.com/serilog/serilog-sinks-azureeventhub" />
<tags>serilog logging azure</tags>
<dependencies>
<dependency id="Serilog" version="[2.2.0,2.5.0]" />
<dependency id="Serilog.Sinks.PeriodicBatching" version="[2,2.1.1]" />
<dependency id="Microsoft.Azure.EventHubs" version="[1.0.3]" />
<dependency id="Azure.Messaging.EventHubs" version="5.*" />
</dependencies>
</metadata>
</package>
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
using System.IO;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Azure.EventHubs;
using Azure.Messaging.EventHubs;
using Azure.Messaging.EventHubs.Producer;
using Serilog.Events;
using Serilog.Formatting;
using Serilog.Sinks.PeriodicBatching;
Expand All @@ -29,7 +30,7 @@ namespace Serilog.Sinks.AzureEventHub
/// </summary>
public class AzureEventHubBatchingSink : PeriodicBatchingSink
{
private readonly EventHubClient _eventHubClient;
private readonly EventHubProducerClient _eventHubClient;
private readonly ITextFormatter _formatter;

/// <summary>
Expand All @@ -40,7 +41,7 @@ public class AzureEventHubBatchingSink : PeriodicBatchingSink
/// <param name="batchSizeLimit"></param>
/// <param name="period"></param>
public AzureEventHubBatchingSink(
EventHubClient eventHubClient,
EventHubProducerClient eventHubClient,
ITextFormatter formatter,
int batchSizeLimit,
TimeSpan period)
Expand Down Expand Up @@ -83,7 +84,7 @@ protected override Task EmitBatchAsync(IEnumerable<LogEvent> events)

batchedEvents.Add(eventHubData);
}
return _eventHubClient.SendAsync(batchedEvents, batchPartitionKey);
return _eventHubClient.SendAsync(batchedEvents, new SendEventOptions() { PartitionKey = batchPartitionKey });
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
// limitations under the License.

using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Microsoft.Azure.EventHubs;
using Azure.Messaging.EventHubs;
using Azure.Messaging.EventHubs.Producer;
using Serilog.Core;
using Serilog.Events;
using Serilog.Formatting;
Expand All @@ -27,7 +29,7 @@ namespace Serilog.Sinks.AzureEventHub
/// </summary>
public class AzureEventHubSink : ILogEventSink
{
readonly EventHubClient _eventHubClient;
readonly EventHubProducerClient _eventHubClient;
readonly ITextFormatter _formatter;

/// <summary>
Expand All @@ -36,7 +38,7 @@ public class AzureEventHubSink : ILogEventSink
/// <param name="eventHubClient">The EventHubClient to use in this sink.</param>
/// <param name="formatter">Provides formatting for outputting log data</param>
public AzureEventHubSink(
EventHubClient eventHubClient,
EventHubProducerClient eventHubClient,
ITextFormatter formatter)
{
_eventHubClient = eventHubClient;
Expand All @@ -61,7 +63,7 @@ public void Emit(LogEvent logEvent)

//Unfortunately no support for async in Serilog yet
//https://github.com/serilog/serilog/issues/134
_eventHubClient.SendAsync(eventHubData, Guid.NewGuid().ToString()).GetAwaiter().GetResult();
_eventHubClient.SendAsync(new List<EventData>() { eventHubData } , new SendEventOptions() { PartitionKey = Guid.NewGuid().ToString() }).GetAwaiter().GetResult();
}
}
}

0 comments on commit f022131

Please sign in to comment.