Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump Serilog from 3.1.1 to 4.0.0 #210

Merged
merged 2 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sample/Sample/Sample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog" Version="4.0.0" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.0" />
Expand Down
5 changes: 2 additions & 3 deletions src/Serilog.Sinks.Splunk/Serilog.Sinks.Splunk.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">

<Import Project="../common.props"/>
<Import Project="../common.props" />

<PropertyGroup>
<Description>The Splunk Sink for Serilog</Description>
Expand All @@ -18,8 +18,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog.Sinks.PeriodicBatching" Version="4.1.1" />
<PackageReference Include="Serilog" Version="4.0.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
using Serilog.Formatting.Json;
using Serilog.Parsing;
using System;
using System.Globalization;
using System.IO;
using System.Linq;

Expand Down
6 changes: 1 addition & 5 deletions src/Serilog.Sinks.Splunk/Sinks/Splunk/CustomField.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Generic;

namespace Serilog.Sinks.Splunk
{ /// <summary>
Expand Down
6 changes: 1 addition & 5 deletions src/Serilog.Sinks.Splunk/Sinks/Splunk/CustomFields.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Generic;

namespace Serilog.Sinks.Splunk
{
Expand Down
17 changes: 7 additions & 10 deletions src/Serilog.Sinks.Splunk/Sinks/Splunk/EventCollectorSink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using Serilog.Core;
using Serilog.Debugging;
using Serilog.Events;
using Serilog.Formatting;
using Serilog.Sinks.PeriodicBatching;
using System;
using System.Collections.Generic;
using System.IO;
Expand Down Expand Up @@ -177,15 +177,15 @@ public EventCollectorSink(
: new EventCollectorClient(eventCollectorToken);
}

/// <summary>
/// Emit a batch of log events, running asynchronously.
/// </summary>
/// <param name="events">The events to emit.</param>
public virtual async Task EmitBatchAsync(IEnumerable<LogEvent> events)
/// <inheritdoc />
public virtual Task OnEmptyBatchAsync() => Task.CompletedTask;

/// <inheritdoc />
public virtual async Task EmitBatchAsync(IReadOnlyCollection<LogEvent> batch)
{
var allEvents = new StringWriter();

foreach (var logEvent in events)
foreach (var logEvent in batch)
{
_jsonFormatter.Format(logEvent, allEvents);
}
Expand All @@ -210,8 +210,5 @@ public virtual async Task EmitBatchAsync(IEnumerable<LogEvent> events)
}
}
}

/// <inheritdoc />
public Task OnEmptyBatchAsync() => Task.CompletedTask;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
using Serilog.Formatting.Json;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;

namespace Serilog.Sinks.Splunk
Expand Down
26 changes: 9 additions & 17 deletions src/Serilog.Sinks.Splunk/SplunkLoggingConfigurationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
using Serilog.Core;
using Serilog.Events;
using Serilog.Formatting;
using Serilog.Sinks.PeriodicBatching;
using Serilog.Sinks.Splunk;
using System;
using System.Net.Http;
Expand Down Expand Up @@ -73,10 +72,10 @@ public static LoggerConfiguration EventCollector(
{
if (configuration == null) throw new ArgumentNullException(nameof(configuration));

var batchingOptions = new PeriodicBatchingSinkOptions
var batchingOptions = new BatchingOptions
{
BatchSizeLimit = batchSizeLimit,
Period = TimeSpan.FromSeconds(batchIntervalInSeconds),
BufferingTimeLimit = TimeSpan.FromSeconds(batchIntervalInSeconds),
EagerlyEmitFirstEvent = true,
QueueLimit = queueLimit
};
Expand All @@ -95,9 +94,7 @@ public static LoggerConfiguration EventCollector(
messageHandler: messageHandler,
subSecondPrecision: subSecondPrecision);

var batchingSink = new PeriodicBatchingSink(eventCollectorSink, batchingOptions);

return configuration.Sink(batchingSink, restrictedToMinimumLevel, levelSwitch);
return configuration.Sink(eventCollectorSink, batchingOptions, restrictedToMinimumLevel, levelSwitch);
}

/// <summary>
Expand Down Expand Up @@ -132,10 +129,10 @@ public static LoggerConfiguration EventCollector(
if (jsonFormatter == null) throw new ArgumentNullException(nameof(jsonFormatter));


var batchingOptions = new PeriodicBatchingSinkOptions
var batchingOptions = new BatchingOptions
{
BatchSizeLimit = batchSizeLimit,
Period = TimeSpan.FromSeconds(batchIntervalInSeconds),
BufferingTimeLimit = TimeSpan.FromSeconds(batchIntervalInSeconds),
EagerlyEmitFirstEvent = true,
QueueLimit = queueLimit
};
Expand All @@ -147,9 +144,7 @@ public static LoggerConfiguration EventCollector(
jsonFormatter,
messageHandler);

var batchingSink = new PeriodicBatchingSink(eventCollectorSink, batchingOptions);

return configuration.Sink(batchingSink, restrictedToMinimumLevel, levelSwitch);
return configuration.Sink(eventCollectorSink, batchingOptions, restrictedToMinimumLevel, levelSwitch);
}


Expand Down Expand Up @@ -199,10 +194,10 @@ public static LoggerConfiguration EventCollector(
{
if (configuration == null) throw new ArgumentNullException(nameof(configuration));

var batchingOptions = new PeriodicBatchingSinkOptions
var batchingOptions = new BatchingOptions
{
BatchSizeLimit = batchSizeLimit,
Period = TimeSpan.FromSeconds(batchIntervalInSeconds),
BufferingTimeLimit = TimeSpan.FromSeconds(batchIntervalInSeconds),
EagerlyEmitFirstEvent = true,
QueueLimit = queueLimit
};
Expand All @@ -223,10 +218,7 @@ public static LoggerConfiguration EventCollector(
subSecondPrecision: subSecondPrecision
);


var batchingSink = new PeriodicBatchingSink(eventCollectorSink, batchingOptions);

return configuration.Sink(batchingSink, restrictedToMinimumLevel, levelSwitch);
return configuration.Sink(eventCollectorSink, batchingOptions, restrictedToMinimumLevel, levelSwitch);
}
}
}
3 changes: 1 addition & 2 deletions src/Serilog.Sinks.UDP/Sinks/Splunk/UdpSink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using Serilog.Sinks.PeriodicBatching;

namespace Serilog.Sinks.Splunk
{
Expand Down Expand Up @@ -74,7 +73,7 @@
}


protected void Dispose(bool disposing)

Check warning on line 76 in src/Serilog.Sinks.UDP/Sinks/Splunk/UdpSink.cs

View workflow job for this annotation

GitHub Actions / CI Build

Missing XML comment for publicly visible type or member 'UdpSink.Dispose(bool)'

Check warning on line 76 in src/Serilog.Sinks.UDP/Sinks/Splunk/UdpSink.cs

View workflow job for this annotation

GitHub Actions / CI Build

Missing XML comment for publicly visible type or member 'UdpSink.Dispose(bool)'

Check warning on line 76 in src/Serilog.Sinks.UDP/Sinks/Splunk/UdpSink.cs

View workflow job for this annotation

GitHub Actions / CI Build

Missing XML comment for publicly visible type or member 'UdpSink.Dispose(bool)'
{
DisposeSocket();
}
Expand All @@ -95,7 +94,7 @@
/// or <see cref="M:Serilog.Sinks.PeriodicBatching.PeriodicBatchingSink.EmitBatchAsync(System.Collections.Generic.IEnumerable{Serilog.Events.LogEvent})" />,
/// not both.
/// </remarks>
public async Task EmitBatchAsync(IEnumerable<LogEvent> batch)
public async Task EmitBatchAsync(IReadOnlyCollection<LogEvent> batch)

Check warning on line 97 in src/Serilog.Sinks.UDP/Sinks/Splunk/UdpSink.cs

View workflow job for this annotation

GitHub Actions / CI Build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 97 in src/Serilog.Sinks.UDP/Sinks/Splunk/UdpSink.cs

View workflow job for this annotation

GitHub Actions / CI Build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 97 in src/Serilog.Sinks.UDP/Sinks/Splunk/UdpSink.cs

View workflow job for this annotation

GitHub Actions / CI Build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
foreach (var logEvent in batch)
{
Expand Down
17 changes: 6 additions & 11 deletions src/Serilog.Sinks.UDP/SplunkLoggingConfigurationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
using Serilog.Configuration;
using Serilog.Events;
using Serilog.Formatting;
using Serilog.Sinks.PeriodicBatching;
using Serilog.Sinks.Splunk;
using System;

Expand Down Expand Up @@ -44,19 +43,17 @@ public static LoggerConfiguration SplunkViaUdp(
bool renderTemplate = true,
bool renderMessage = true)
{
var batchingOptions = new PeriodicBatchingSinkOptions
var batchingOptions = new BatchingOptions
{
BatchSizeLimit = connectionInfo.BatchPostingLimit,
Period = connectionInfo.Period,
BufferingTimeLimit = connectionInfo.Period,
EagerlyEmitFirstEvent = true,
QueueLimit = connectionInfo.QueueSizeLimit
};

var sink = new UdpSink(connectionInfo, formatProvider, renderTemplate, renderMessage);

var batchingSink = new PeriodicBatchingSink(sink, batchingOptions);

return loggerConfiguration.Sink(batchingSink, restrictedToMinimumLevel);
return loggerConfiguration.Sink(sink, batchingOptions, restrictedToMinimumLevel);
}

/// <summary>
Expand All @@ -73,19 +70,17 @@ public static LoggerConfiguration SplunkViaUdp(
ITextFormatter formatter,
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum)
{
var batchingOptions = new PeriodicBatchingSinkOptions
var batchingOptions = new BatchingOptions
{
BatchSizeLimit = connectionInfo.BatchPostingLimit,
Period = connectionInfo.Period,
BufferingTimeLimit = connectionInfo.Period,
EagerlyEmitFirstEvent = true,
QueueLimit = connectionInfo.QueueSizeLimit
};

var sink = new UdpSink(connectionInfo, formatter);

var batchingSink = new PeriodicBatchingSink(sink, batchingOptions);

return loggerConfiguration.Sink(batchingSink, restrictedToMinimumLevel);
return loggerConfiguration.Sink(sink, batchingOptions, restrictedToMinimumLevel);
}
}
}
2 changes: 1 addition & 1 deletion src/common.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<VersionPrefix Condition=" '$(VersionPrefix)' == '' ">4.1.1</VersionPrefix>
<VersionPrefix Condition=" '$(VersionPrefix)' == '' ">5.0.0</VersionPrefix>
<VersionSuffix Condition="$(VersionSuffix) == '' and '$(Configuration)' == 'Debug' ">debug</VersionSuffix>
<Authors>Matthew Erbs, Serilog Contributors</Authors>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand Down
6 changes: 0 additions & 6 deletions test/Serilog.Sinks.Splunk.TCP.Tests/TCPCollectorTests.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Serilog.Events;
using Xunit;

Expand Down
4 changes: 1 addition & 3 deletions test/Serilog.Sinks.Splunk.Tests/EpochExtensionsTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Serilog.Sinks.Splunk;
using System;
using System.Diagnostics;
using System;
using Xunit;

namespace Serilog.Sinks.Splunk.Tests
Expand Down
Loading