Skip to content

Commit

Permalink
refactor: dont inherit sealed class
Browse files Browse the repository at this point in the history
  • Loading branch information
FantasticFiasco committed Apr 2, 2024
1 parent ab1c866 commit 9754860
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 33 deletions.
12 changes: 10 additions & 2 deletions src/Serilog.Sinks.Udp/LoggerSinkConfigurationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using Serilog.Sinks.Udp.Private;
using Serilog.Core;
using Serilog.Debugging;
using Serilog.Sinks.PeriodicBatching;

namespace Serilog;

Expand Down Expand Up @@ -171,9 +172,16 @@ public static LoggerConfiguration Udp(
try
{
var client = UdpClientFactory.Create(localPort, family, enableBroadcast);
var sink = new BatchingSink(new UdpSink(client, remoteAddress, remotePort, formatter, encoding));
var udpSink = new UdpSink(client, remoteAddress, remotePort, formatter, encoding);
var batchingSink = new PeriodicBatchingSink(
udpSink,
new PeriodicBatchingSinkOptions
{
BatchSizeLimit = 1000,
Period = TimeSpan.FromSeconds(0.5)
});

return sinkConfiguration.Sink(sink, restrictedToMinimumLevel, levelSwitch);
return sinkConfiguration.Sink(batchingSink, restrictedToMinimumLevel, levelSwitch);
}
catch (Exception e)
{
Expand Down
31 changes: 0 additions & 31 deletions src/Serilog.Sinks.Udp/Sinks/Udp/Private/BatchingSink.cs

This file was deleted.

0 comments on commit 9754860

Please sign in to comment.