Skip to content

Commit

Permalink
Merge pull request #87 from serilog/dev
Browse files Browse the repository at this point in the history
5.0.0 Release
  • Loading branch information
nblumhardt authored Jun 5, 2024
2 parents 7c9b3bc + 4ec8720 commit 649fc9a
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 462 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

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

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

Sinks that, for performance reasons, need to emit events in batches, can be implemented using `PeriodicBatchingSink`
Expand Down
5 changes: 4 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ build_script:
test: off
artifacts:
- path: artifacts/Serilog.*.nupkg
- path: artifacts/Serilog.*.snupkg
deploy:
- provider: NuGet
api_key:
Expand All @@ -16,7 +17,9 @@ deploy:
- provider: GitHub
auth_token:
secure: p4LpVhBKxGS5WqucHxFQ5c7C8cP74kbNB0Z8k9Oxx/PMaDQ1+ibmoexNqVU5ZlmX
artifact: /Serilog.*\.nupkg/
artifact:
/Serilog.*\.nupkg/
/Serilog.*\.snupkg/
tag: v$(appveyor_build_version)
on:
branch: main
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@

<PropertyGroup>
<Description>Buffer batches of log events to be flushed asynchronously.</Description>
<VersionPrefix>4.1.1</VersionPrefix>
<VersionPrefix>5.0.0</VersionPrefix>
<Authors>Serilog Contributors</Authors>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">net462</TargetFrameworks>
<TargetFrameworks>$(TargetFrameworks);netstandard2.0;net6.0</TargetFrameworks>
<Authors>Serilog Contributors</Authors>
<!-- .NET Framework version targeting is frozen at these two TFMs. -->
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT'">net471;net462</TargetFrameworks>
<!-- Policy is to trim TFM-specific builds to `netstandard2.0`, `net6.0`,
all active LTS versions, and optionally the latest RTM version, when releasing new
major Serilog versions. -->
<TargetFrameworks>$(TargetFrameworks);net8.0;net6.0;netstandard2.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<RootNamespace>Serilog</RootNamespace>
<PackageTags>serilog;batching;timer</PackageTags>
Expand All @@ -16,18 +21,18 @@
<RepositoryType>git</RepositoryType>
<Nullable>enable</Nullable>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
<PropertyGroup Condition=" '$(TargetFramework)' == 'net6.0' or '$(TargetFramework)' == 'net8.0' ">
<DefineConstants>$(DefineConstants);FEATURE_ASYNCDISPOSABLE</DefineConstants>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' OR '$(TargetFramework)' == 'net462'">
<PackageReference Include="System.Threading.Channels" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog" Version="4.0.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using Serilog.Events;

namespace Serilog.Sinks.PeriodicBatching;

sealed class LegacyBatchedSinkAdapter: Core.IBatchedLogEventSink, IDisposable
#if FEATURE_ASYNCDISPOSABLE
, IAsyncDisposable
#endif
{
readonly IBatchedLogEventSink _inner;
readonly bool _dispose;

public LegacyBatchedSinkAdapter(IBatchedLogEventSink inner, bool dispose)
{
_inner = inner;
_dispose = dispose;
}

public Task EmitBatchAsync(IReadOnlyCollection<LogEvent> batch)
{
return _inner.EmitBatchAsync(batch);
}

public Task OnEmptyBatchAsync()
{
return _inner.OnEmptyBatchAsync();
}

public void Dispose()
{
if (!_dispose)
return;

(_inner as IDisposable)?.Dispose();
}

#if FEATURE_ASYNCDISPOSABLE
public async ValueTask DisposeAsync()
{
if (!_dispose)
return;

if (_inner is IAsyncDisposable asyncDisposable)
{
await asyncDisposable.DisposeAsync();
}
else
{
Dispose();
}
}
#endif
}
Loading

0 comments on commit 649fc9a

Please sign in to comment.