Skip to content

Commit 947d047

Browse files
committed
Update to Serilog 4, align TFMs, enable strict null checks, remove redundant configuration overloads
1 parent be07b80 commit 947d047

File tree

5 files changed

+29
-77
lines changed

5 files changed

+29
-77
lines changed
Lines changed: 5 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
using System;
2-
using System.ComponentModel;
32
using Serilog.Configuration;
43
using Serilog.Sinks.Async;
5-
using Serilog.Events;
64

75
namespace Serilog
86
{
@@ -11,44 +9,6 @@ namespace Serilog
119
/// </summary>
1210
public static class LoggerConfigurationAsyncExtensions
1311
{
14-
/// <summary>
15-
/// Configure a sink to be invoked asynchronously, on a background worker thread.
16-
/// </summary>
17-
/// <param name="loggerSinkConfiguration">The <see cref="LoggerSinkConfiguration"/> being configured.</param>
18-
/// <param name="configure">An action that configures the wrapped sink.</param>
19-
/// <param name="bufferSize">The size of the concurrent queue used to feed the background worker thread. If
20-
/// the thread is unable to process events quickly enough and the queue is filled, subsequent events will be
21-
/// dropped until room is made in the queue.</param>
22-
/// <returns>A <see cref="LoggerConfiguration"/> allowing configuration to continue.</returns>
23-
[EditorBrowsable(EditorBrowsableState.Never)]
24-
public static LoggerConfiguration Async(
25-
this LoggerSinkConfiguration loggerSinkConfiguration,
26-
Action<LoggerSinkConfiguration> configure,
27-
int bufferSize)
28-
{
29-
return loggerSinkConfiguration.Async(configure, bufferSize, false);
30-
}
31-
32-
/// <summary>
33-
/// Configure a sink to be invoked asynchronously, on a background worker thread.
34-
/// </summary>
35-
/// <param name="loggerSinkConfiguration">The <see cref="LoggerSinkConfiguration"/> being configured.</param>
36-
/// <param name="configure">An action that configures the wrapped sink.</param>
37-
/// <param name="bufferSize">The size of the concurrent queue used to feed the background worker thread. If
38-
/// the thread is unable to process events quickly enough and the queue is filled, depending on
39-
/// <paramref name="blockWhenFull"/> the queue will block or subsequent events will be dropped until
40-
/// room is made in the queue.</param>
41-
/// <param name="blockWhenFull">Block when the queue is full, instead of dropping events.</param>
42-
/// <returns>A <see cref="LoggerConfiguration"/> allowing configuration to continue.</returns>
43-
public static LoggerConfiguration Async(
44-
this LoggerSinkConfiguration loggerSinkConfiguration,
45-
Action<LoggerSinkConfiguration> configure,
46-
int bufferSize = 10000,
47-
bool blockWhenFull = false)
48-
{
49-
return loggerSinkConfiguration.Async(configure, null, bufferSize, blockWhenFull);
50-
}
51-
5212
/// <summary>
5313
/// Configure a sink to be invoked asynchronously, on a background worker thread.
5414
/// Accepts a reference to a <paramref name="monitor"/> that will be supplied the internal state interface for health monitoring purposes.
@@ -65,16 +25,14 @@ public static LoggerConfiguration Async(
6525
public static LoggerConfiguration Async(
6626
this LoggerSinkConfiguration loggerSinkConfiguration,
6727
Action<LoggerSinkConfiguration> configure,
68-
IAsyncLogEventSinkMonitor monitor,
6928
int bufferSize = 10000,
70-
bool blockWhenFull = false)
29+
bool blockWhenFull = false,
30+
IAsyncLogEventSinkMonitor? monitor = null)
7131
{
72-
return LoggerSinkConfiguration.Wrap(
73-
loggerSinkConfiguration,
32+
var wrapper = LoggerSinkConfiguration.Wrap(
7433
wrappedSink => new BackgroundWorkerSink(wrappedSink, bufferSize, blockWhenFull, monitor),
75-
configure,
76-
LevelAlias.Minimum,
77-
null);
34+
configure);
35+
return loggerSinkConfiguration.Sink(wrapper);
7836
}
7937
}
8038
}

src/Serilog.Sinks.Async/Serilog.Sinks.Async.csproj

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,50 @@
22

33
<PropertyGroup>
44
<Description>Asynchronous sink wrapper for Serilog.</Description>
5-
<VersionPrefix>1.5.1</VersionPrefix>
5+
<VersionPrefix>2.0.0</VersionPrefix>
66
<Authors>Jezz Santos;Serilog Contributors</Authors>
7-
<TargetFrameworks>net45;netstandard1.1;net461;netstandard2.0</TargetFrameworks>
7+
<!-- .NET Framework version targeting is frozen at these two TFMs. -->
8+
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT'">net471;net462</TargetFrameworks>
9+
<!-- Policy is to trim TFM-specific builds to `netstandard2.0`, `net6.0`,
10+
all active LTS versions, and optionally the latest RTM version, when releasing new
11+
major Serilog versions. -->
12+
<TargetFrameworks>$(TargetFrameworks);net8.0;net6.0;netstandard2.0</TargetFrameworks>
813
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
914
<GenerateDocumentationFile>true</GenerateDocumentationFile>
10-
<AssemblyName>Serilog.Sinks.Async</AssemblyName>
1115
<RootNamespace>Serilog</RootNamespace>
1216
<AssemblyOriginatorKeyFile>../../assets/Serilog.snk</AssemblyOriginatorKeyFile>
1317
<SignAssembly>true</SignAssembly>
1418
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
15-
<PackageId>Serilog.Sinks.Async</PackageId>
1619
<PackageTags>serilog;async</PackageTags>
1720
<PackageIcon>serilog-sink-nuget.png</PackageIcon>
1821
<PackageProjectUrl>https://serilog.net</PackageProjectUrl>
1922
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
2023
<RepositoryUrl>https://github.com/serilog/serilog-sinks-async</RepositoryUrl>
2124
<RepositoryType>git</RepositoryType>
2225
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
26+
<PackageReadmeFile>README.md</PackageReadmeFile>
27+
<LangVersion>12</LangVersion>
28+
<Nullable>enable</Nullable>
2329
</PropertyGroup>
2430

25-
<PropertyGroup Condition=" '$(TargetFramework)' == 'net45' Or '$(TargetFramework)' == 'net461' ">
26-
<!-- Don't reference the full NETStandard.Library -->
27-
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
28-
</PropertyGroup>
29-
3031
<ItemGroup>
31-
<PackageReference Include="Serilog" Version="2.9.0" />
32+
<PackageReference Include="Serilog" Version="4.0.0" />
33+
<PackageReference Include="Nullable" Version="1.3.1" PrivateAssets="all" />
34+
</ItemGroup>
35+
36+
<ItemGroup Condition=" '$(TargetFramework)' == 'net471' ">
37+
<Reference Include="System" />
38+
<Reference Include="Microsoft.CSharp" />
3239
</ItemGroup>
3340

34-
<ItemGroup Condition=" '$(TargetFramework)' == 'net45' Or '$(TargetFramework)' == 'net461' ">
41+
<ItemGroup Condition=" '$(TargetFramework)' == 'net462' ">
3542
<Reference Include="System" />
3643
<Reference Include="Microsoft.CSharp" />
3744
</ItemGroup>
3845

3946
<ItemGroup>
40-
<None Include="..\..\assets\serilog-sink-nuget.png">
41-
<Pack>True</Pack>
42-
<PackagePath></PackagePath>
43-
</None>
47+
<None Include="..\..\assets\serilog-sink-nuget.png" Pack="true" Visible="false" PackagePath="/" />
48+
<None Include="..\..\README.md" Pack="true" Visible="false" PackagePath="/" />
4449
</ItemGroup>
4550

4651
</Project>

src/Serilog.Sinks.Async/Sinks/Async/BackgroundWorkerSink.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ sealed class BackgroundWorkerSink : ILogEventSink, IAsyncLogEventSinkInspector,
1414
readonly bool _blockWhenFull;
1515
readonly BlockingCollection<LogEvent> _queue;
1616
readonly Task _worker;
17-
readonly IAsyncLogEventSinkMonitor _monitor;
17+
readonly IAsyncLogEventSinkMonitor? _monitor;
1818

1919
long _droppedMessages;
2020

21-
public BackgroundWorkerSink(ILogEventSink wrappedSink, int bufferCapacity, bool blockWhenFull, IAsyncLogEventSinkMonitor monitor = null)
21+
public BackgroundWorkerSink(ILogEventSink wrappedSink, int bufferCapacity, bool blockWhenFull, IAsyncLogEventSinkMonitor? monitor = null)
2222
{
2323
if (bufferCapacity <= 0) throw new ArgumentOutOfRangeException(nameof(bufferCapacity));
2424
_wrappedSink = wrappedSink ?? throw new ArgumentNullException(nameof(wrappedSink));

test/Serilog.Sinks.Async.PerformanceTests/Serilog.Sinks.Async.PerformanceTests.csproj

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net461;netcoreapp2.0</TargetFrameworks>
5-
<AssemblyName>Serilog.Sinks.Async.PerformanceTests</AssemblyName>
4+
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
65
<AssemblyOriginatorKeyFile>../../assets/Serilog.snk</AssemblyOriginatorKeyFile>
76
<SignAssembly>true</SignAssembly>
87
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
@@ -27,8 +26,4 @@
2726
<PackageReference Include="Serilog.Sinks.File" Version="3.1.0" />
2827
</ItemGroup>
2928

30-
<ItemGroup>
31-
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
32-
</ItemGroup>
33-
3429
</Project>

test/Serilog.Sinks.Async.Tests/Serilog.Sinks.Async.Tests.csproj

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net461;netcoreapp2.0</TargetFrameworks>
5-
<AssemblyName>Serilog.Sinks.Async.Tests</AssemblyName>
4+
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
65
<AssemblyOriginatorKeyFile>../../assets/Serilog.snk</AssemblyOriginatorKeyFile>
76
<SignAssembly>true</SignAssembly>
87
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
9-
<PackageId>Serilog.Sinks.Async.Tests</PackageId>
108
</PropertyGroup>
119

1210
<ItemGroup>
@@ -22,8 +20,4 @@
2220
<PackageReference Include="xunit" Version="2.4.1" />
2321
</ItemGroup>
2422

25-
<ItemGroup>
26-
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
27-
</ItemGroup>
28-
2923
</Project>

0 commit comments

Comments
 (0)