Skip to content

Commit d7bcb06

Browse files
authored
Merge pull request #27 from serilog/dev
4.0.0 Release
2 parents b6fc3aa + 8728e10 commit d7bcb06

File tree

12 files changed

+184
-149
lines changed

12 files changed

+184
-149
lines changed

.idea/.idea.serilog-sinks-trace/.idea/.gitignore

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.idea.serilog-sinks-trace/.idea/encodings.xml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.idea.serilog-sinks-trace/.idea/indexLayout.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.idea.serilog-sinks-trace/.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Build.ps1

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,24 @@ if(Test-Path .\artifacts) {
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];
1414
$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

2124
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-
29-
if($LASTEXITCODE -ne 0) { exit 1 }
30-
31-
Pop-Location
32-
}
33-
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 }
32+
if($LASTEXITCODE -ne 0) { throw "build failed" }
4133

4234
Pop-Location
4335
}
@@ -48,9 +40,9 @@ foreach ($test in ls test/*.Tests) {
4840
echo "build: Testing project in $test"
4941

5042
& dotnet test -c Release
51-
if($LASTEXITCODE -ne 0) { exit 3 }
43+
if($LASTEXITCODE -ne 0) { throw "tests failed" }
5244

5345
Pop-Location
5446
}
5547

56-
Pop-Location
48+
Pop-Location

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Serilog.Sinks.Trace [![Build status](https://ci.appveyor.com/api/projects/status/v1oe03lx3wymyy7j/branch/master?svg=true)](https://ci.appveyor.com/project/serilog/serilog-sinks-trace/branch/master) [![NuGet Version](http://img.shields.io/nuget/v/Serilog.Sinks.Trace.svg?style=flat)](https://www.nuget.org/packages/Serilog.Sinks.Trace/)
22

3+
> **Note:** this sink writes regular log events to `System.Diagnostics.Trace`. If you're looking for
4+
> distributed/hierarchical tracing with Serilog, see [SerilogTracing](https://github.com/serilog-tracing/serilog-tracing)
5+
> instead.
6+
37
Writes [Serilog](https://serilog.net) events to `System.Diagnostics.Trace`.
48

59
```csharp

appveyor.yml

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
version: '{build}'
22
skip_tags: true
3-
image: Visual Studio 2019
4-
configuration: Release
5-
test: off
3+
image: Visual Studio 2022
64
build_script:
7-
- ps: ./Build.ps1
5+
- pwsh: ./Build.ps1
6+
test: off
87
artifacts:
9-
- path: artifacts/Serilog.*.nupkg
8+
- path: artifacts/Serilog.*.nupkg
109
deploy:
11-
- provider: NuGet
12-
api_key:
13-
secure: rbdBqxBpLt4MkB+mrDOYNDOd8aVZ1zMkysaVNAXNKnC41FYifzX3l9LM8DCrUWU5
14-
skip_symbols: true
15-
on:
16-
branch: /^(main|dev)$/
17-
- provider: GitHub
18-
auth_token:
19-
secure: p4LpVhBKxGS5WqucHxFQ5c7C8cP74kbNB0Z8k9Oxx/PMaDQ1+ibmoexNqVU5ZlmX
20-
artifact: /Serilog.*\.nupkg/
21-
tag: v$(appveyor_build_version)
22-
on:
23-
branch: main
10+
- provider: NuGet
11+
api_key:
12+
secure: ZpUO4ECx4c/V0Ecj04cfV1UGd+ZABeEG9DDW2fjG8vITjNYhmbiiJH0qNOnRy2G3
13+
skip_symbols: true
14+
on:
15+
branch: /^(main|dev)$/
16+
- provider: GitHub
17+
auth_token:
18+
secure: p4LpVhBKxGS5WqucHxFQ5c7C8cP74kbNB0Z8k9Oxx/PMaDQ1+ibmoexNqVU5ZlmX
19+
artifact: /Serilog.*\.nupkg/
20+
tag: v$(appveyor_build_version)
21+
on:
22+
branch: main

serilog-sinks-trace.sln

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "global", "global", "{EF92FC
1616
ProjectSection(SolutionItems) = preProject
1717
appveyor.yml = appveyor.yml
1818
Build.ps1 = Build.ps1
19-
NuGet.Config = NuGet.Config
2019
README.md = README.md
2120
EndProjectSection
2221
EndProject
Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,38 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<Description>The diagnostic trace sink for Serilog.</Description>
5-
<VersionPrefix>3.0.0</VersionPrefix>
6-
<Authors>Serilog Contributors</Authors>
7-
<TargetFrameworks>net45;netstandard1.3;netstandard2.0</TargetFrameworks>
8-
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
9-
<GenerateDocumentationFile>true</GenerateDocumentationFile>
10-
<AssemblyOriginatorKeyFile>../../assets/Serilog.snk</AssemblyOriginatorKeyFile>
11-
<SignAssembly>true</SignAssembly>
12-
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
13-
<PackageTags>serilog;trace;diagnostic</PackageTags>
14-
<PackageProjectUrl>https://github.com/serilog/serilog-sinks-trace</PackageProjectUrl>
15-
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
16-
<PackageIcon>serilog-sink-nuget.png</PackageIcon>
17-
</PropertyGroup>
3+
<PropertyGroup>
4+
<Description>The System.Diagnostics.Trace sink for Serilog.</Description>
5+
<VersionPrefix>4.0.0</VersionPrefix>
6+
<Authors>Serilog Contributors</Authors>
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>
13+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
14+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
15+
<AssemblyOriginatorKeyFile>../../assets/Serilog.snk</AssemblyOriginatorKeyFile>
16+
<SignAssembly>true</SignAssembly>
17+
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
18+
<PackageTags>serilog;trace;diagnostic</PackageTags>
19+
<PackageProjectUrl>https://github.com/serilog/serilog-sinks-trace</PackageProjectUrl>
20+
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
21+
<PackageIcon>serilog-sink-nuget.png</PackageIcon>
22+
<LangVersion>12</LangVersion>
23+
<Nullable>enable</Nullable>
24+
<PackageReadmeFile>README.md</PackageReadmeFile>
25+
<RootNamespace>Serilog</RootNamespace>
26+
</PropertyGroup>
1827

19-
<ItemGroup>
20-
<PackageReference Include="Serilog" Version="2.10.0" />
21-
</ItemGroup>
28+
<ItemGroup>
29+
<PackageReference Include="Serilog" Version="4.0.0"/>
30+
<PackageReference Include="Nullable" Version="1.3.1" PrivateAssets="all"/>
31+
</ItemGroup>
2232

23-
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
24-
<PackageReference Include="System.Diagnostics.TraceSource" Version="4.3.0" />
25-
</ItemGroup>
26-
27-
<ItemGroup>
28-
<None Include="..\..\assets\serilog-sink-nuget.png">
29-
<Pack>True</Pack>
30-
<PackagePath></PackagePath>
31-
</None>
32-
</ItemGroup>
33+
<ItemGroup>
34+
<None Include="..\..\assets\serilog-sink-nuget.png" Pack="true" Visible="false" PackagePath="/" />
35+
<None Include="..\..\README.md" Pack="true" Visible="false" PackagePath="/" />
36+
</ItemGroup>
3337

3438
</Project>

src/Serilog.Sinks.Trace/Sinks/Trace/TraceSink.cs

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,40 +13,45 @@
1313
// limitations under the License.
1414

1515
using System;
16-
using System.Diagnostics;
1716
using System.IO;
1817
using Serilog.Core;
1918
using Serilog.Events;
2019
using Serilog.Formatting;
2120

22-
namespace Serilog.Sinks.DiagnosticTrace
21+
namespace Serilog.Sinks.Trace;
22+
23+
class TraceSink : ILogEventSink
2324
{
24-
class TraceSink : ILogEventSink
25-
{
26-
readonly ITextFormatter _textFormatter;
25+
readonly ITextFormatter _textFormatter;
2726

28-
public TraceSink(ITextFormatter textFormatter)
29-
{
30-
if (textFormatter == null) throw new ArgumentNullException(nameof(textFormatter));
31-
_textFormatter = textFormatter;
32-
}
27+
public TraceSink(ITextFormatter textFormatter)
28+
{
29+
_textFormatter = textFormatter;
30+
}
3331

34-
public void Emit(LogEvent logEvent)
35-
{
36-
if (logEvent == null) throw new ArgumentNullException(nameof(logEvent));
37-
var sr = new StringWriter();
38-
_textFormatter.Format(logEvent, sr);
32+
public void Emit(LogEvent logEvent)
33+
{
34+
if (logEvent == null) throw new ArgumentNullException(nameof(logEvent));
35+
var sr = new StringWriter();
36+
_textFormatter.Format(logEvent, sr);
3937

40-
var text = sr.ToString().Trim();
38+
var text = sr.ToString().Trim();
4139

42-
if (logEvent.Level == LogEventLevel.Error || logEvent.Level == LogEventLevel.Fatal)
43-
Trace.TraceError(text);
44-
else if (logEvent.Level == LogEventLevel.Warning)
45-
Trace.TraceWarning(text);
46-
else if (logEvent.Level == LogEventLevel.Information)
47-
Trace.TraceInformation(text);
48-
else
49-
Trace.WriteLine(text);
40+
switch (logEvent.Level)
41+
{
42+
case LogEventLevel.Error:
43+
case LogEventLevel.Fatal:
44+
System.Diagnostics.Trace.TraceError(text);
45+
break;
46+
case LogEventLevel.Warning:
47+
System.Diagnostics.Trace.TraceWarning(text);
48+
break;
49+
case LogEventLevel.Information:
50+
System.Diagnostics.Trace.TraceInformation(text);
51+
break;
52+
default:
53+
System.Diagnostics.Trace.WriteLine(text);
54+
break;
5055
}
5156
}
52-
}
57+
}

0 commit comments

Comments
 (0)