Skip to content

Commit f0e20b1

Browse files
authored
Merge pull request #95 from nblumhardt/serilog-4
Serilog 4 updates
2 parents 6ff6c82 + 6cd51b8 commit f0e20b1

21 files changed

+791
-821
lines changed

Build.ps1

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,41 +11,33 @@ if(Test-Path .\artifacts) {
1111

1212
$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL];
1313
$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
14-
$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "master" -and $revision -ne "local"]
14+
$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "main" -and $revision -ne "local"]
15+
$commitHash = $(git rev-parse --short HEAD)
16+
$buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""]
1517

16-
echo "build: Version suffix is $suffix"
18+
echo "build: Package version suffix is $suffix"
19+
echo "build: Build version suffix is $buildSuffix"
1720

1821
foreach ($src in ls src/*) {
1922
Push-Location $src
2023

21-
echo "build: Packaging project in $src"
24+
echo "build: Packaging project in $src"
2225

26+
& dotnet build -c Release --version-suffix=$buildSuffix -p:EnableSourceLink=true
2327
if ($suffix) {
24-
& dotnet pack -c Release -o ..\..\artifacts --version-suffix=$suffix --include-source
28+
& dotnet pack -c Release -o ..\..\artifacts --version-suffix=$suffix --no-build
2529
} else {
26-
& dotnet pack -c Release -o ..\..\artifacts --include-source
30+
& dotnet pack -c Release -o ..\..\artifacts --no-build
2731
}
28-
2932
if($LASTEXITCODE -ne 0) { exit 1 }
3033

3134
Pop-Location
3235
}
3336

34-
foreach ($test in ls test/*.PerformanceTests) {
35-
Push-Location $test
36-
37-
echo "build: Building performance test project in $test"
38-
39-
& dotnet build -c Release
40-
if($LASTEXITCODE -ne 0) { exit 2 }
41-
42-
Pop-Location
43-
}
44-
4537
foreach ($test in ls test/*.Tests) {
4638
Push-Location $test
4739

48-
echo "build: Testing project in $test"
40+
echo "build: Testing project in $test"
4941

5042
& dotnet test -c Release
5143
if($LASTEXITCODE -ne 0) { exit 3 }

appveyor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
version: '{build}'
22
skip_tags: true
3-
image: Visual Studio 2019
3+
image: Visual Studio 2022
44
build_script:
5-
- ps: ./Build.ps1
5+
- pwsh: ./Build.ps1
66
test: off
77
artifacts:
88
- path: artifacts/Serilog.*.nupkg
Lines changed: 42 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,51 @@
1-
using System;
2-
using System.ComponentModel;
1+
// Copyright © Serilog Contributors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
using System;
316
using Serilog.Configuration;
417
using Serilog.Sinks.Async;
5-
using Serilog.Events;
618

7-
namespace Serilog
19+
namespace Serilog;
20+
21+
/// <summary>
22+
/// Extends <see cref="LoggerConfiguration"/> with methods for configuring asynchronous logging.
23+
/// </summary>
24+
public static class LoggerConfigurationAsyncExtensions
825
{
926
/// <summary>
10-
/// Extends <see cref="LoggerConfiguration"/> with methods for configuring asynchronous logging.
27+
/// Configure a sink to be invoked asynchronously, on a background worker thread.
28+
/// Accepts a reference to a <paramref name="monitor"/> that will be supplied the internal state interface for health monitoring purposes.
1129
/// </summary>
12-
public static class LoggerConfigurationAsyncExtensions
30+
/// <param name="loggerSinkConfiguration">The <see cref="LoggerSinkConfiguration"/> being configured.</param>
31+
/// <param name="configure">An action that configures the wrapped sink.</param>
32+
/// <param name="bufferSize">The size of the concurrent queue used to feed the background worker thread. If
33+
/// the thread is unable to process events quickly enough and the queue is filled, depending on
34+
/// <paramref name="blockWhenFull"/> the queue will block or subsequent events will be dropped until
35+
/// room is made in the queue.</param>
36+
/// <param name="blockWhenFull">Block when the queue is full, instead of dropping events.</param>
37+
/// <param name="monitor">Monitor to supply buffer information to.</param>
38+
/// <returns>A <see cref="LoggerConfiguration"/> allowing configuration to continue.</returns>
39+
public static LoggerConfiguration Async(
40+
this LoggerSinkConfiguration loggerSinkConfiguration,
41+
Action<LoggerSinkConfiguration> configure,
42+
int bufferSize = 10000,
43+
bool blockWhenFull = false,
44+
IAsyncLogEventSinkMonitor? monitor = null)
1345
{
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-
52-
/// <summary>
53-
/// Configure a sink to be invoked asynchronously, on a background worker thread.
54-
/// Accepts a reference to a <paramref name="monitor"/> that will be supplied the internal state interface for health monitoring purposes.
55-
/// </summary>
56-
/// <param name="loggerSinkConfiguration">The <see cref="LoggerSinkConfiguration"/> being configured.</param>
57-
/// <param name="configure">An action that configures the wrapped sink.</param>
58-
/// <param name="bufferSize">The size of the concurrent queue used to feed the background worker thread. If
59-
/// the thread is unable to process events quickly enough and the queue is filled, depending on
60-
/// <paramref name="blockWhenFull"/> the queue will block or subsequent events will be dropped until
61-
/// room is made in the queue.</param>
62-
/// <param name="blockWhenFull">Block when the queue is full, instead of dropping events.</param>
63-
/// <param name="monitor">Monitor to supply buffer information to.</param>
64-
/// <returns>A <see cref="LoggerConfiguration"/> allowing configuration to continue.</returns>
65-
public static LoggerConfiguration Async(
66-
this LoggerSinkConfiguration loggerSinkConfiguration,
67-
Action<LoggerSinkConfiguration> configure,
68-
IAsyncLogEventSinkMonitor monitor,
69-
int bufferSize = 10000,
70-
bool blockWhenFull = false)
71-
{
72-
return LoggerSinkConfiguration.Wrap(
73-
loggerSinkConfiguration,
74-
wrappedSink => new BackgroundWorkerSink(wrappedSink, bufferSize, blockWhenFull, monitor),
75-
configure,
76-
LevelAlias.Minimum,
77-
null);
78-
}
46+
var wrapper = LoggerSinkConfiguration.Wrap(
47+
wrappedSink => new BackgroundWorkerSink(wrappedSink, bufferSize, blockWhenFull, monitor),
48+
configure);
49+
return loggerSinkConfiguration.Sink(wrapper);
7950
}
8051
}

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

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,40 @@
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-
</ItemGroup>
33-
34-
<ItemGroup Condition=" '$(TargetFramework)' == 'net45' Or '$(TargetFramework)' == 'net461' ">
35-
<Reference Include="System" />
36-
<Reference Include="Microsoft.CSharp" />
32+
<PackageReference Include="Serilog" Version="4.0.0" />
33+
<PackageReference Include="Nullable" Version="1.3.1" PrivateAssets="all" />
3734
</ItemGroup>
3835

3936
<ItemGroup>
40-
<None Include="..\..\assets\serilog-sink-nuget.png">
41-
<Pack>True</Pack>
42-
<PackagePath></PackagePath>
43-
</None>
37+
<None Include="..\..\assets\serilog-sink-nuget.png" Pack="true" Visible="false" PackagePath="/" />
38+
<None Include="..\..\README.md" Pack="true" Visible="false" PackagePath="/" />
4439
</ItemGroup>
4540

4641
</Project>

0 commit comments

Comments
 (0)