From d9a4ca5751dfa76421def24e60b768bc319ff99e Mon Sep 17 00:00:00 2001 From: Jeff Dye Date: Wed, 6 Dec 2017 16:26:13 -0500 Subject: [PATCH 1/2] Changes mirroring Serilog.Sinks.Seq --- sample/Sample/Sample.csproj | 13 ++++++++++--- .../Serilog.Sinks.Splunk.csproj | 14 +++++++------- .../Serilog.Sinks.Splunk.Tests.csproj | 9 +++++++-- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/sample/Sample/Sample.csproj b/sample/Sample/Sample.csproj index 541aaa2..529ff7b 100644 --- a/sample/Sample/Sample.csproj +++ b/sample/Sample/Sample.csproj @@ -2,12 +2,19 @@ Exe - netcoreapp2.0 + netcoreapp2.0;net47 - - + + + + + + + + + diff --git a/src/Serilog.Sinks.Splunk/Serilog.Sinks.Splunk.csproj b/src/Serilog.Sinks.Splunk/Serilog.Sinks.Splunk.csproj index f18aaa6..80e0304 100644 --- a/src/Serilog.Sinks.Splunk/Serilog.Sinks.Splunk.csproj +++ b/src/Serilog.Sinks.Splunk/Serilog.Sinks.Splunk.csproj @@ -2,7 +2,7 @@ The Splunk Sink for Serilog - 2.4.0 + 2.5.0 Matthew Erbs, Serilog Contributors net45;netstandard1.1;netstandard1.3 true @@ -15,6 +15,10 @@ false + + $(DefineConstants);TCP;UDP + + @@ -22,22 +26,18 @@ - - $(DefineConstants);TCP;UDP - - + - + - diff --git a/test/Serilog.Sinks.Splunk.Tests/Serilog.Sinks.Splunk.Tests.csproj b/test/Serilog.Sinks.Splunk.Tests/Serilog.Sinks.Splunk.Tests.csproj index 40da3da..9f8c25f 100644 --- a/test/Serilog.Sinks.Splunk.Tests/Serilog.Sinks.Splunk.Tests.csproj +++ b/test/Serilog.Sinks.Splunk.Tests/Serilog.Sinks.Splunk.Tests.csproj @@ -19,6 +19,7 @@ + @@ -26,11 +27,15 @@ - + - + + + + + From 912c362df177b4b5aafd9d62fcedac6dbf906365 Mon Sep 17 00:00:00 2001 From: Van Nguyen Date: Sat, 13 Jan 2018 12:57:27 +1100 Subject: [PATCH 2/2] Add optional LoggingLevelSwitch param to EventCollector extension methods --- .../SplunkLoggingConfigurationExtensions.cs | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/Serilog.Sinks.Splunk/SplunkLoggingConfigurationExtensions.cs b/src/Serilog.Sinks.Splunk/SplunkLoggingConfigurationExtensions.cs index 50ef4e6..f85705f 100644 --- a/src/Serilog.Sinks.Splunk/SplunkLoggingConfigurationExtensions.cs +++ b/src/Serilog.Sinks.Splunk/SplunkLoggingConfigurationExtensions.cs @@ -16,6 +16,7 @@ using System; using System.Net.Http; using Serilog.Configuration; +using Serilog.Core; using Serilog.Events; using Serilog.Formatting; using Serilog.Sinks.Splunk; @@ -53,6 +54,7 @@ public static class SplunkLoggingConfigurationExtensions /// The interval in seconds that the queue should be instpected for batching /// The size of the batch /// The handler used to send HTTP requests + /// A switch allowing the pass-through minimum level to be changed at runtime. /// public static LoggerConfiguration EventCollector( this LoggerSinkConfiguration configuration, @@ -69,7 +71,8 @@ public static LoggerConfiguration EventCollector( bool renderTemplate = true, int batchIntervalInSeconds = 2, int batchSizeLimit = 100, - HttpMessageHandler messageHandler = null) + HttpMessageHandler messageHandler = null, + LoggingLevelSwitch levelSwitch = null) { if (configuration == null) throw new ArgumentNullException(nameof(configuration)); if (outputTemplate == null) throw new ArgumentNullException(nameof(outputTemplate)); @@ -88,7 +91,7 @@ public static LoggerConfiguration EventCollector( renderTemplate, messageHandler); - return configuration.Sink(eventCollectorSink, restrictedToMinimumLevel); + return configuration.Sink(eventCollectorSink, restrictedToMinimumLevel, levelSwitch); } /// @@ -104,6 +107,7 @@ public static LoggerConfiguration EventCollector( /// The interval in seconds that the queue should be instpected for batching /// The size of the batch /// The handler used to send HTTP requests + /// A switch allowing the pass-through minimum level to be changed at runtime. /// public static LoggerConfiguration EventCollector( this LoggerSinkConfiguration configuration, @@ -115,7 +119,8 @@ public static LoggerConfiguration EventCollector( string outputTemplate = DefaultOutputTemplate, int batchIntervalInSeconds = 2, int batchSizeLimit = 100, - HttpMessageHandler messageHandler = null) + HttpMessageHandler messageHandler = null, + LoggingLevelSwitch levelSwitch = null) { if (configuration == null) throw new ArgumentNullException(nameof(configuration)); if (jsonFormatter == null) throw new ArgumentNullException(nameof(jsonFormatter)); @@ -130,10 +135,10 @@ public static LoggerConfiguration EventCollector( jsonFormatter, messageHandler); - return configuration.Sink(eventCollectorSink, restrictedToMinimumLevel); + return configuration.Sink(eventCollectorSink, restrictedToMinimumLevel, levelSwitch); } - + /// /// Adds a sink that writes log events as to a Splunk instance via the HTTP Event Collector. /// @@ -152,6 +157,7 @@ public static LoggerConfiguration EventCollector( /// The interval in seconds that the queue should be instpected for batching /// The size of the batch /// The handler used to send HTTP requests + /// A switch allowing the pass-through minimum level to be changed at runtime. /// Customfields that will be indexed in splunk with this event /// public static LoggerConfiguration EventCollector( @@ -170,7 +176,8 @@ public static LoggerConfiguration EventCollector( bool renderTemplate = true, int batchIntervalInSeconds = 2, int batchSizeLimit = 100, - HttpMessageHandler messageHandler = null) + HttpMessageHandler messageHandler = null, + LoggingLevelSwitch levelSwitch = null) { if (configuration == null) throw new ArgumentNullException(nameof(configuration)); if (outputTemplate == null) throw new ArgumentNullException(nameof(outputTemplate)); @@ -191,7 +198,7 @@ public static LoggerConfiguration EventCollector( messageHandler ); - return configuration.Sink(eventCollectorSink, restrictedToMinimumLevel); + return configuration.Sink(eventCollectorSink, restrictedToMinimumLevel, levelSwitch); } } } \ No newline at end of file