Skip to content

Commit

Permalink
Merge pull request #92 from steffenlyng/development
Browse files Browse the repository at this point in the history
Merge PR #90 and bump version
  • Loading branch information
madslyng authored Sep 12, 2019
2 parents ad6790e + ebb666c commit 56cda53
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 2 deletions.
10 changes: 10 additions & 0 deletions .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
name: Question
about: General questions regarding Serilog.Sinks.RabbitMq
title: ''
labels: question
assignees: ''

---


Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
// limitations under the License.

using System;
using RabbitMQ.Client;
using Serilog.Configuration;
using Serilog.Formatting;
using Serilog.Sinks.RabbitMQ;
using Serilog.Sinks.RabbitMQ.Sinks.RabbitMQ;

Expand Down Expand Up @@ -41,10 +43,73 @@ public static LoggerConfiguration RabbitMQ(
return RegisterSink(loggerConfiguration, clientConfiguration, sinkConfiguration);
}

/// <summary>
/// Adds a sink that lets you push log messages to RabbitMQ
/// Will be used when configuring via configuration file
/// If you need to overrule the text formatter, you will need to supply it here as a separate parameter instead of supplying it via the RabbitMQSinkConfiguration instance
/// which will not work when configuring via configuration file
/// </summary>
public static LoggerConfiguration RabbitMQ(
this LoggerSinkConfiguration loggerConfiguration,
RabbitMQClientConfiguration clientConfiguration, RabbitMQSinkConfiguration sinkConfiguration, ITextFormatter textFormatter = null)
{
if (textFormatter != null) sinkConfiguration.TextFormatter = textFormatter;
return RegisterSink(loggerConfiguration, clientConfiguration, sinkConfiguration);
}

/// <summary>
/// Adds a sink that lets you push log messages to RabbitMQ
/// Will be used when configuring via configuration file
/// Is for backward-compatibility with previous version
/// </summary>
public static LoggerConfiguration RabbitMQ(
this LoggerSinkConfiguration loggerConfiguration,
RabbitMQClientConfiguration clientConfiguration, RabbitMQSinkConfiguration sinkConfiguration)
string hostname, string username, string password, string exchange = null, string exchangeType = null,
RabbitMQDeliveryMode deliveryMode = RabbitMQDeliveryMode.NonDurable, string routeKey = null, int port = 0,
string vHost = null, ushort heartbeat = 0, IProtocol protocol = null, int batchPostingLimit = 0,
TimeSpan period = default(TimeSpan), ITextFormatter formatter = null, IFormatProvider formatProvider = null
)
{
return loggerConfiguration.RabbitMQ(new string[] {hostname}, username, password, exchange, exchangeType,
deliveryMode, routeKey, port, vHost, heartbeat, protocol, batchPostingLimit, period, formatter);
}

/// <summary>
/// Adds a sink that lets you push log messages to RabbitMQ
/// Will be used when configuring via configuration file
/// Is for backward-compatibility with previous version but gives possibility to use multiple hosts
/// </summary>
public static LoggerConfiguration RabbitMQ(
this LoggerSinkConfiguration loggerConfiguration,
string[] hostnames, string username, string password, string exchange = null, string exchangeType = null,
RabbitMQDeliveryMode deliveryMode = RabbitMQDeliveryMode.NonDurable, string routeKey = null, int port = 0,
string vHost = null, ushort heartbeat = 0, IProtocol protocol = null, int batchPostingLimit = 0,
TimeSpan period = default, ITextFormatter formatter = null
)
{
RabbitMQClientConfiguration clientConfiguration = new RabbitMQClientConfiguration
{
Username = username,
Password = password,
Exchange = exchange,
ExchangeType = exchangeType,
DeliveryMode = deliveryMode,
RouteKey = routeKey,
Port = port,
VHost = vHost,
Heartbeat = heartbeat,
Protocol = protocol
};
foreach (string hostname in hostnames)
{
clientConfiguration.Hostnames.Add(hostname);
}

RabbitMQSinkConfiguration sinkConfiguration = new RabbitMQSinkConfiguration
{
BatchPostingLimit = batchPostingLimit, Period = period, TextFormatter = formatter
};

return RegisterSink(loggerConfiguration, clientConfiguration, sinkConfiguration);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Serilog.Sinks.RabbitMQ/Serilog.Sinks.RabbitMQ.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<VersionPrefix>3.0.3</VersionPrefix>
<VersionPrefix>3.0.4</VersionPrefix>
<TargetFrameworks>net451;netstandard1.6</TargetFrameworks>
<DebugType>portable</DebugType>
<AssemblyName>Serilog.Sinks.RabbitMQ</AssemblyName>
Expand Down

0 comments on commit 56cda53

Please sign in to comment.