Skip to content

Commit 649fc9a

Browse files
authored
Merge pull request #87 from serilog/dev
5.0.0 Release
2 parents 7c9b3bc + 4ec8720 commit 649fc9a

File tree

7 files changed

+117
-462
lines changed

7 files changed

+117
-462
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
A wrapper for Serilog sinks that asynchronously emits events in batches, useful when logging to a slow and/or remote target.
44

5+
> [!IMPORTANT]
6+
> Serilog 4.x and later versions support batching natively. New projects should use Serilog's `IBatchedLogEventSink` and
7+
> `WriteTo.Sink(IBatchedLogEventSink)`, not this package which is now only maintained for compatibility reasons.
8+
59
### Getting started
610

711
Sinks that, for performance reasons, need to emit events in batches, can be implemented using `PeriodicBatchingSink`

appveyor.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ build_script:
66
test: off
77
artifacts:
88
- path: artifacts/Serilog.*.nupkg
9+
- path: artifacts/Serilog.*.snupkg
910
deploy:
1011
- provider: NuGet
1112
api_key:
@@ -16,7 +17,9 @@ deploy:
1617
- provider: GitHub
1718
auth_token:
1819
secure: p4LpVhBKxGS5WqucHxFQ5c7C8cP74kbNB0Z8k9Oxx/PMaDQ1+ibmoexNqVU5ZlmX
19-
artifact: /Serilog.*\.nupkg/
20+
artifact:
21+
/Serilog.*\.nupkg/
22+
/Serilog.*\.snupkg/
2023
tag: v$(appveyor_build_version)
2124
on:
2225
branch: main

src/Serilog.Sinks.PeriodicBatching/Serilog.Sinks.PeriodicBatching.csproj

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,15 @@
22

33
<PropertyGroup>
44
<Description>Buffer batches of log events to be flushed asynchronously.</Description>
5-
<VersionPrefix>4.1.1</VersionPrefix>
5+
<VersionPrefix>5.0.0</VersionPrefix>
66
<Authors>Serilog Contributors</Authors>
7-
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">net462</TargetFrameworks>
8-
<TargetFrameworks>$(TargetFrameworks);netstandard2.0;net6.0</TargetFrameworks>
7+
<Authors>Serilog Contributors</Authors>
8+
<!-- .NET Framework version targeting is frozen at these two TFMs. -->
9+
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT'">net471;net462</TargetFrameworks>
10+
<!-- Policy is to trim TFM-specific builds to `netstandard2.0`, `net6.0`,
11+
all active LTS versions, and optionally the latest RTM version, when releasing new
12+
major Serilog versions. -->
13+
<TargetFrameworks>$(TargetFrameworks);net8.0;net6.0;netstandard2.0</TargetFrameworks>
914
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1015
<RootNamespace>Serilog</RootNamespace>
1116
<PackageTags>serilog;batching;timer</PackageTags>
@@ -16,18 +21,18 @@
1621
<RepositoryType>git</RepositoryType>
1722
<Nullable>enable</Nullable>
1823
<PackageReadmeFile>README.md</PackageReadmeFile>
24+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
25+
<IncludeSymbols>true</IncludeSymbols>
26+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
1927
</PropertyGroup>
2028

21-
<PropertyGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
29+
<PropertyGroup Condition=" '$(TargetFramework)' == 'net6.0' or '$(TargetFramework)' == 'net8.0' ">
2230
<DefineConstants>$(DefineConstants);FEATURE_ASYNCDISPOSABLE</DefineConstants>
2331
</PropertyGroup>
24-
25-
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' OR '$(TargetFramework)' == 'net462'">
26-
<PackageReference Include="System.Threading.Channels" Version="8.0.0" />
27-
</ItemGroup>
2832

2933
<ItemGroup>
30-
<PackageReference Include="Serilog" Version="3.1.1" />
34+
<PackageReference Include="Serilog" Version="4.0.0" />
35+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
3136
</ItemGroup>
3237

3338
<ItemGroup>

src/Serilog.Sinks.PeriodicBatching/Sinks/PeriodicBatching/FailureAwareBatchScheduler.cs

Lines changed: 0 additions & 88 deletions
This file was deleted.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
using Serilog.Events;
2+
3+
namespace Serilog.Sinks.PeriodicBatching;
4+
5+
sealed class LegacyBatchedSinkAdapter: Core.IBatchedLogEventSink, IDisposable
6+
#if FEATURE_ASYNCDISPOSABLE
7+
, IAsyncDisposable
8+
#endif
9+
{
10+
readonly IBatchedLogEventSink _inner;
11+
readonly bool _dispose;
12+
13+
public LegacyBatchedSinkAdapter(IBatchedLogEventSink inner, bool dispose)
14+
{
15+
_inner = inner;
16+
_dispose = dispose;
17+
}
18+
19+
public Task EmitBatchAsync(IReadOnlyCollection<LogEvent> batch)
20+
{
21+
return _inner.EmitBatchAsync(batch);
22+
}
23+
24+
public Task OnEmptyBatchAsync()
25+
{
26+
return _inner.OnEmptyBatchAsync();
27+
}
28+
29+
public void Dispose()
30+
{
31+
if (!_dispose)
32+
return;
33+
34+
(_inner as IDisposable)?.Dispose();
35+
}
36+
37+
#if FEATURE_ASYNCDISPOSABLE
38+
public async ValueTask DisposeAsync()
39+
{
40+
if (!_dispose)
41+
return;
42+
43+
if (_inner is IAsyncDisposable asyncDisposable)
44+
{
45+
await asyncDisposable.DisposeAsync();
46+
}
47+
else
48+
{
49+
Dispose();
50+
}
51+
}
52+
#endif
53+
}

0 commit comments

Comments
 (0)