Skip to content

Commit 2db445d

Browse files
authored
Merge pull request #54 from pmetz-steelcase/devNet6
Update SDK and targets to match Serilog 3
2 parents 2141692 + 2e30b05 commit 2db445d

File tree

12 files changed

+86
-75
lines changed

12 files changed

+86
-75
lines changed

Build.ps1

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,35 @@
1+
Write-Output "build: Build started"
2+
13
Push-Location $PSScriptRoot
24

3-
if(Test-Path .\artifacts) { Remove-Item .\artifacts -Force -Recurse }
5+
if(Test-Path .\artifacts) {
6+
Write-Output "build: Cleaning .\artifacts"
7+
Remove-Item .\artifacts -Force -Recurse
8+
}
49

5-
& dotnet restore --no-cache
10+
$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$NULL -ne $env:APPVEYOR_REPO_BRANCH];
11+
$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$NULL -ne $env:APPVEYOR_BUILD_NUMBER];
12+
$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "main" -and $revision -ne "local"]
13+
$commitHash = $(git rev-parse --short HEAD)
14+
$buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""]
615

7-
$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL];
8-
$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
9-
$suffix = @{ $true = ""; $false = "$branch-$revision"}[$branch -eq "master" -and $revision -ne "local"]
16+
Write-Output "build: Package version suffix is $suffix"
17+
Write-Output "build: Build version suffix is $buildSuffix"
1018

11-
foreach ($src in ls src/Serilog.*) {
12-
Push-Location $src
19+
& dotnet build --configuration Release --version-suffix=$buildSuffix /p:ContinuousIntegrationBuild=true
1320

14-
& dotnet pack -c Release -o ..\..\.\artifacts --version-suffix=$suffix
15-
if($LASTEXITCODE -ne 0) { exit 1 }
21+
if($LASTEXITCODE -ne 0) { throw 'build failed' }
1622

17-
Pop-Location
23+
if($suffix) {
24+
& dotnet pack src\Serilog.Formatting.Compact --configuration Release --no-build --no-restore -o artifacts --version-suffix=$suffix
25+
} else {
26+
& dotnet pack src\Serilog.Formatting.Compact --configuration Release --no-build --no-restore -o artifacts
1827
}
1928

20-
foreach ($test in ls test/Serilog.*.Tests) {
21-
Push-Location $test
29+
if($LASTEXITCODE -ne 0) { throw 'pack failed' }
2230

23-
& dotnet test -c Release
24-
if($LASTEXITCODE -ne 0) { exit 2 }
31+
Write-Output "build: Testing"
2532

26-
Pop-Location
27-
}
33+
& dotnet test test\Serilog.Formatting.Compact.Tests --configuration Release --no-build --no-restore
2834

29-
Pop-Location
35+
if($LASTEXITCODE -ne 0) { throw 'unit tests failed' }

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
supported targets: netstandard2.0, net6.0
2+
updated packages in test proj

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,3 @@ Several tools are available for working with the CLEF format.
152152
* **[Compact Log Format Viewer](https://github.com/warrenbuckley/Compact-Log-Format-Viewer)** - a cross-platform viewer for CLEF files
153153
* **[`seqcli`](https://github.com/datalust/seqcli)** - pretty-`print` CLEF files at the command-line, or `ingest` CLEF files into [Seq](https://datalust.co/seq) for search, and analysis
154154
* **[_Serilog.Formatting.Compact.Reader_](https://github.com/serilog/serilog-formatting-compact-reader)** - convert CLEF documents back into Serilog `LogEvent`s
155-

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ install:
66
- ps: ./Setup.ps1
77
build_script:
88
- ps: ./Build.ps1
9-
test: off
9+
test: false
1010
artifacts:
1111
- path: artifacts/Serilog.*.nupkg
1212
deploy:

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"sdk": {
3-
"version": "3.0.100"
3+
"version": "7.0.304"
44
}
55
}

src/Serilog.Formatting.Compact/Formatting/Compact/CompactJsonFormatter.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// limitations under the License.
1414

1515
using System;
16+
using System.Globalization;
1617
using System.IO;
1718
using System.Linq;
1819
using Serilog.Events;
@@ -76,12 +77,12 @@ public static void FormatEvent(LogEvent logEvent, TextWriter output, JsonValueFo
7677
{
7778
output.Write(",\"@r\":[");
7879
var delim = "";
79-
foreach (var r in tokensWithFormat)
80+
foreach (PropertyToken r in tokensWithFormat)
8081
{
8182
output.Write(delim);
8283
delim = ",";
8384
var space = new StringWriter();
84-
r.Render(logEvent.Properties, space);
85+
r.Render(logEvent.Properties, space, CultureInfo.InvariantCulture);
8586
JsonValueFormatter.WriteQuotedJsonString(space.ToString(), output);
8687
}
8788
output.Write(']');

src/Serilog.Formatting.Compact/Formatting/Compact/RenderedCompactJsonFormatter.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// limitations under the License.
1414

1515
using System;
16+
using System.Globalization;
1617
using System.IO;
1718
using Serilog.Events;
1819
using Serilog.Formatting.Json;
@@ -63,11 +64,11 @@ public static void FormatEvent(LogEvent logEvent, TextWriter output, JsonValueFo
6364
output.Write("{\"@t\":\"");
6465
output.Write(logEvent.Timestamp.UtcDateTime.ToString("O"));
6566
output.Write("\",\"@m\":");
66-
var message = logEvent.MessageTemplate.Render(logEvent.Properties);
67+
var message = logEvent.MessageTemplate.Render(logEvent.Properties, CultureInfo.InvariantCulture);
6768
JsonValueFormatter.WriteQuotedJsonString(message, output);
6869
output.Write(",\"@i\":\"");
6970
var id = EventIdHash.Compute(logEvent.MessageTemplate.Text);
70-
output.Write(id.ToString("x8"));
71+
output.Write(id.ToString("x8",CultureInfo.InvariantCulture));
7172
output.Write('"');
7273

7374
if (logEvent.Level != LogEventLevel.Information)
Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,33 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<Description>A simple, compact JSON-based event format for Serilog.</Description>
5-
<VersionPrefix>1.1.1</VersionPrefix>
6-
<Authors>Serilog Contributors</Authors>
7-
<TargetFrameworks>net452;netstandard1.1;netstandard2.0</TargetFrameworks>
8-
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
9-
<GenerateDocumentationFile>true</GenerateDocumentationFile>
10-
<AssemblyName>Serilog.Formatting.Compact</AssemblyName>
11-
<AssemblyOriginatorKeyFile>../../assets/Serilog.snk</AssemblyOriginatorKeyFile>
12-
<SignAssembly>true</SignAssembly>
13-
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
14-
<PackageId>Serilog.Formatting.Compact</PackageId>
15-
<PackageTags>serilog;json</PackageTags>
16-
<PackageIconUrl>http://serilog.net/images/serilog-extension-nuget.png</PackageIconUrl>
17-
<PackageProjectUrl>https://github.com/serilog/serilog-formatting-compact</PackageProjectUrl>
18-
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
19-
</PropertyGroup>
3+
<PropertyGroup>
4+
<Description>A simple, compact JSON-based event format for Serilog.</Description>
5+
<VersionPrefix>2.0.0</VersionPrefix>
6+
<Authors>Serilog Contributors</Authors>
7+
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT'">net462;net471</TargetFrameworks>
8+
<TargetFrameworks>$(TargetFrameworks);netstandard2.0;netstandard2.1;net6.0;net7.0</TargetFrameworks>
9+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
10+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
11+
<AssemblyOriginatorKeyFile>../../assets/Serilog.snk</AssemblyOriginatorKeyFile>
12+
<SignAssembly>true</SignAssembly>
13+
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
14+
<PackageIcon>serilog-extension-nuget.png</PackageIcon>
15+
<PackageTags>serilog;json</PackageTags>
16+
<PackageProjectUrl>https://github.com/serilog/serilog-formatting-compact</PackageProjectUrl>
17+
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
18+
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
19+
<RepositoryUrl>https://github.com/serilog/serilog-formatting-compact</RepositoryUrl>
20+
<RepositoryType>git</RepositoryType>
21+
<AnalysisLevel>6.0-recommended</AnalysisLevel>
22+
</PropertyGroup>
2023

21-
<ItemGroup>
22-
<PackageReference Include="Serilog" Version="2.9.0" />
23-
</ItemGroup>
24+
<PropertyGroup Condition="'$(TargetFramework)'=='netstandard2.0'">
25+
<WarningLevel>5</WarningLevel>
26+
</PropertyGroup>
2427

25-
<ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
26-
<Reference Include="System" />
27-
<Reference Include="Microsoft.CSharp" />
28-
</ItemGroup>
28+
<ItemGroup>
29+
<PackageReference Include="Serilog" Version="3.0.1" />
30+
<None Include="serilog-extension-nuget.png" Pack="True" Visible="False" PackagePath="" />
31+
</ItemGroup>
2932

3033
</Project>
21.9 KB
Loading

test/Serilog.Formatting.Compact.Tests/FormattingBenchmarks.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public FormattingBenchmarks()
3030

3131
StringWriter _buffer;
3232

33-
[Setup]
33+
[GlobalSetup]
3434
public void InitBuffer()
3535
{
3636
_buffer = new StringWriter();

0 commit comments

Comments
 (0)