Skip to content

Commit

Permalink
Add support for netstandard2.0
Browse files Browse the repository at this point in the history
Requires reverting the code to C# 7.3 and making the DisposeAsync conditional on the net6.0 build
  • Loading branch information
a-jackson committed May 20, 2024
1 parent 8bcf04e commit 360c0c1
Show file tree
Hide file tree
Showing 4 changed files with 301 additions and 295 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static LoggerConfiguration AmazonCloudWatch(this LoggerSinkConfiguration
// the batched sink is
var batchedSink = new PeriodicBatchingSinkImplementationCallback(cloudWatchClient, options);

var sink = new PeriodicBatchingSink(batchedSink, new()
var sink = new PeriodicBatchingSink(batchedSink, new PeriodicBatchingSinkOptions()
{
BatchSizeLimit = options.BatchSizeLimit,
Period = options.Period,
Expand Down
9 changes: 7 additions & 2 deletions src/Serilog.Sinks.AwsCloudWatch/CloudWatchLogSink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ namespace Serilog.Sinks.AwsCloudWatch
/// <summary>
/// A Serilog log sink that publishes to AWS CloudWatch Logs
/// </summary>
public class CloudWatchLogSink : ILogEventSink, IDisposable, IAsyncDisposable
public class CloudWatchLogSink : ILogEventSink, IDisposable
#if NET6_0_OR_GREATER
, IAsyncDisposable
#endif
{
private readonly PeriodicBatchingSink batchingSink;

Expand Down Expand Up @@ -52,7 +55,7 @@ public class CloudWatchLogSink : ILogEventSink, IDisposable, IAsyncDisposable
public CloudWatchLogSink(IAmazonCloudWatchLogs cloudWatchClient, ICloudWatchSinkOptions options)
{
var batchedSink = new PeriodicBatchingSinkImplementationCallback(cloudWatchClient, options);
batchingSink = new(batchedSink, new() { BatchSizeLimit = options.BatchSizeLimit, Period = options.Period, QueueLimit = options.QueueSizeLimit });
batchingSink = new PeriodicBatchingSink(batchedSink, new PeriodicBatchingSinkOptions() { BatchSizeLimit = options.BatchSizeLimit, Period = options.Period, QueueLimit = options.QueueSizeLimit });
}

/// <inheritdoc/>
Expand All @@ -67,10 +70,12 @@ public void Dispose()
batchingSink.Dispose();
}

#if NET6_0_OR_GREATER
/// <inheritdoc/>
public ValueTask DisposeAsync()
{
return batchingSink.DisposeAsync();
}
#endif
}
}
Loading

0 comments on commit 360c0c1

Please sign in to comment.