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

Avoid stack overflow when disposing batched sink #134

Merged
merged 3 commits into from
Apr 2, 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
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Serilog.Formatting;
using Serilog.Formatting.Json;
using Serilog.Sinks.AwsCloudWatch.LogStreamNameProvider;
using Serilog.Sinks.PeriodicBatching;

namespace Serilog.Sinks.AwsCloudWatch
{
Expand Down Expand Up @@ -37,9 +38,16 @@ public static LoggerConfiguration AmazonCloudWatch(this LoggerSinkConfiguration
{
throw new ArgumentNullException(nameof(cloudWatchClient));
}

// the batched sink is
var batchedSink = new PeriodicBatchingSinkImplementationCallback(cloudWatchClient, options);

// create the sink
var sink = new CloudWatchLogSink(cloudWatchClient, options);
var sink = new PeriodicBatchingSink(batchedSink, new()
{
BatchSizeLimit = options.BatchSizeLimit,
Period = options.Period,
QueueLimit = options.QueueSizeLimit
});

// register the sink
return loggerConfiguration.Sink(sink, options.MinimumLogEventLevel);
Expand Down Expand Up @@ -180,10 +188,8 @@ public static LoggerConfiguration AmazonCloudWatch(
}

var client = cloudWatchClient ?? new AmazonCloudWatchLogsClient();

// Create and register the sink
var sink = new CloudWatchLogSink(client, options);
return loggerConfiguration.Sink(sink, options.MinimumLogEventLevel);

return AmazonCloudWatch(loggerConfiguration, options, client);
}
}
}
Loading
Loading