Skip to content

Commit

Permalink
Merge pull request #238 from datalust/dev
Browse files Browse the repository at this point in the history
9.0.0 Release
  • Loading branch information
KodrAus authored Dec 20, 2024
2 parents fbc68c1 + fef7c92 commit 7060727
Show file tree
Hide file tree
Showing 45 changed files with 335 additions and 226 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# If this file is renamed, the incrementing run attempt number will be reset.

name: CI

on:
push:
branches: [ "dev", "main" ]
pull_request:
branches: [ "dev", "main" ]

env:
CI_BUILD_NUMBER_BASE: ${{ github.run_number }}
CI_TARGET_BRANCH: ${{ github.head_ref || github.ref_name }}

jobs:
build:

# The build must run on Windows so that .NET Framework targets can be built and tested.
runs-on: windows-latest

permissions:
contents: write

steps:
- uses: actions/checkout@v4
- name: Setup
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
- name: Compute build number
shell: bash
run: |
echo "CI_BUILD_NUMBER=$(($CI_BUILD_NUMBER_BASE+2300))" >> $GITHUB_ENV
- name: Build and Publish
env:
DOTNET_CLI_TELEMETRY_OPTOUT: true
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: pwsh
run: |
./Build.ps1
88 changes: 67 additions & 21 deletions Build.ps1
Original file line number Diff line number Diff line change
@@ -1,33 +1,79 @@
Write-Output "build: Tool versions follow"

dotnet --version
dotnet --list-sdks

Write-Output "build: Build started"

Push-Location $PSScriptRoot
try {
if(Test-Path .\artifacts) {
Write-Output "build: Cleaning ./artifacts"
Remove-Item ./artifacts -Force -Recurse
}

if(Test-Path .\artifacts) { Remove-Item .\artifacts -Force -Recurse }
& dotnet restore --no-cache

& dotnet restore --no-cache
$dbp = [Xml] (Get-Content .\Directory.Version.props)
$versionPrefix = $dbp.Project.PropertyGroup.VersionPrefix

$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL];
$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
$suffix = @{ $true = ""; $false = "$branch-$revision"}[$branch -eq "main" -and $revision -ne "local"]
Write-Output "build: Package version prefix is $versionPrefix"

foreach ($src in gci src/Serilog.*) {
Push-Location $src
$branch = @{ $true = $env:CI_TARGET_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$NULL -ne $env:CI_TARGET_BRANCH];
$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:CI_BUILD_NUMBER, 10); $false = "local" }[$NULL -ne $env:CI_BUILD_NUMBER];
$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)) -replace '([^a-zA-Z0-9\-]*)', '')-$revision"}[$branch -eq "main" -and $revision -ne "local"]
$commitHash = $(git rev-parse --short HEAD)
$buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""]

if ($suffix) {
& dotnet pack -c Release -o ..\..\.\artifacts --version-suffix=$suffix --include-source
} else {
& dotnet pack -c Release -o ..\..\.\artifacts --include-source
}
if($LASTEXITCODE -ne 0) { exit 1 }
Write-Output "build: Package version suffix is $suffix"
Write-Output "build: Build version suffix is $buildSuffix"

Pop-Location
}
& dotnet build -c Release --version-suffix=$buildSuffix /p:ContinuousIntegrationBuild=true
if($LASTEXITCODE -ne 0) { throw "Build failed" }

foreach ($src in Get-ChildItem src/*) {
Push-Location $src

Write-Output "build: Packaging project in $src"

if ($suffix) {
& dotnet pack -c Release --no-build --no-restore -o ../../artifacts --version-suffix=$suffix
} else {
& dotnet pack -c Release --no-build --no-restore -o ../../artifacts
}
if($LASTEXITCODE -ne 0) { throw "Packaging failed" }

foreach ($test in gci test/Serilog.*.Tests) {
Push-Location $test
Pop-Location
}

& dotnet test -c Release
if($LASTEXITCODE -ne 0) { exit 2 }
foreach ($test in Get-ChildItem test/*.Tests) {
Push-Location $test

Write-Output "build: Testing project in $test"

& dotnet test -c Release --no-build --no-restore
if($LASTEXITCODE -ne 0) { throw "Testing failed" }

Pop-Location
}

if ($env:NUGET_API_KEY) {
# GitHub Actions will only supply this to branch builds and not PRs. We publish
# builds from any branch this action targets (i.e. main and dev).

Write-Output "build: Publishing NuGet packages"

foreach ($nupkg in Get-ChildItem artifacts/*.nupkg) {
& dotnet nuget push -k $env:NUGET_API_KEY -s https://api.nuget.org/v3/index.json "$nupkg"
if($LASTEXITCODE -ne 0) { throw "Publishing failed" }
}

if (!($suffix)) {
Write-Output "build: Creating release for version $versionPrefix"

iex "gh release create v$versionPrefix --title v$versionPrefix --generate-notes $(get-item ./artifacts/*.nupkg) $(get-item ./artifacts/*.snupkg)"
}
}
} finally {
Pop-Location
}

Pop-Location
17 changes: 17 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project>
<Import Project="$(MSBuildThisFileDirectory)Directory.Version.props" />
<PropertyGroup>
<LangVersion>latest</LangVersion>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)assets/Serilog.snk</AssemblyOriginatorKeyFile>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>
</Project>
5 changes: 5 additions & 0 deletions Directory.Version.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project>
<PropertyGroup>
<VersionPrefix>9.0.0</VersionPrefix>
</PropertyGroup>
</Project>
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Serilog.Sinks.Seq [![Build status](https://ci.appveyor.com/api/projects/status/uwkn795klja7u74f/branch/dev?svg=true)](https://ci.appveyor.com/project/datalust/serilog-sinks-seq/branch/dev) [![NuGet](https://img.shields.io/nuget/v/Serilog.Sinks.Seq.svg)](https://nuget.org/packages/serilog.sinks.seq)
# Serilog.Sinks.Seq&nbsp;[![Build status](https://github.com/datalust/serilog-sinks-seq/actions/workflows/ci.yml/badge.svg?branch=dev)](https://github.com/datalust/serilog-sinks-seq/actions)&nbsp;[![NuGet](https://img.shields.io/nuget/v/Serilog.Sinks.Seq.svg)](https://nuget.org/packages/serilog.sinks.seq)

A Serilog sink that writes events to the [Seq](https://datalust.co/seq) structured log server. Supports all modern .NET platforms.

[<img alt="Package Logo" src="https://datalust.co/images/seq-nuget.png" width="128px">](https://nuget.org/packages/serilog.sinks.seq)

> [!TIP]
> If you would like to see timing and dependency information in Seq, [SerilogTracing](https://github.com/serilog-tracing/serilog-tracing) is a Serilog extension that supports both logs and traces.
> If you would like to see timing and dependency information in Seq, [SerilogTracing](https://github.com/serilog-tracing/serilog-tracing) is a Serilog extension that can send both logs and traces through this sink.

### Getting started
Expand Down
30 changes: 0 additions & 30 deletions appveyor.yml

This file was deleted.

3 changes: 2 additions & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"sdk": {
"version": "8.0.201",
"version": "9.0.100",
"allowPrerelease": false,
"rollForward": "latestFeature"
}
}
10 changes: 5 additions & 5 deletions sample/BlazorWasm/BlazorWasm.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<TargetFramework>net9.0</TargetFramework>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<SignAssembly>false</SignAssembly>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.4" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="9.0.0" PrivateAssets="all" />
<PackageReference Include="serilog.extensions.logging" Version="8.0.0" />
<PackageReference Include="serilog.sinks.browserconsole" Version="2.0.0" />
</ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions sample/Sample/Program.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using System.Linq;
using System.Threading;
using Serilog;
using Serilog;
using Serilog.Core;
using Serilog.Debugging;

SelfLog.Enable(Console.Error);

// By sharing between the Seq sink and logger itself,
// Seq API keys can be used to control the level of the whole logging pipeline.
Expand Down
8 changes: 3 additions & 5 deletions sample/Sample/Sample.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<OutputType>Exe</OutputType>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
13 changes: 11 additions & 2 deletions serilog-sinks-seq.sln
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,28 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample", "sample\Sample\Sam
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Serilog.Sinks.Seq.Tests", "test\Serilog.Sinks.Seq.Tests\Serilog.Sinks.Seq.Tests.csproj", "{3C2D8E01-5580-426A-BDD9-EC59CD98E618}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sln", "sln", "{27A8DEB5-B04B-4DCB-8CF2-0049E5EE66AF}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".sln", ".sln", "{27A8DEB5-B04B-4DCB-8CF2-0049E5EE66AF}"
ProjectSection(SolutionItems) = preProject
appveyor.yml = appveyor.yml
Build.ps1 = Build.ps1
README.md = README.md
.gitattributes = .gitattributes
.gitignore = .gitignore
CHANGES.md = CHANGES.md
global.json = global.json
LICENSE = LICENSE
Directory.Build.props = Directory.Build.props
Directory.Version.props = Directory.Version.props
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlazorWasm", "sample\BlazorWasm\BlazorWasm.csproj", "{1BB4C500-449C-42DF-849D-F0CAEC9965EE}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{02D526DA-1D26-4B37-BC72-54B42CC4C185}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{8FE857C7-CD70-4FC2-98D6-022580B70659}"
ProjectSection(SolutionItems) = preProject
.github\workflows\ci.yml = .github\workflows\ci.yml
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -66,5 +74,6 @@ Global
{17497155-5D94-45DF-81D9-BD960E8CF217} = {88A3ECD1-D91A-49A2-A6D7-5A70973A0E3F}
{3C2D8E01-5580-426A-BDD9-EC59CD98E618} = {67B1C971-75EE-4ABE-B184-66AAC8D9D572}
{1BB4C500-449C-42DF-849D-F0CAEC9965EE} = {88A3ECD1-D91A-49A2-A6D7-5A70973A0E3F}
{8FE857C7-CD70-4FC2-98D6-022580B70659} = {02D526DA-1D26-4B37-BC72-54B42CC4C185}
EndGlobalSection
EndGlobal
8 changes: 0 additions & 8 deletions src/Serilog.Sinks.Seq/Properties/AssemblyInfo.cs

This file was deleted.

17 changes: 10 additions & 7 deletions src/Serilog.Sinks.Seq/SeqLoggerConfigurationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using Serilog.Configuration;
using Serilog.Core;
using Serilog.Events;
using Serilog.Sinks.Seq;
using System.Net.Http;
using Serilog.Formatting;
using Serilog.Sinks.Seq.Batched;
using Serilog.Sinks.Seq.Audit;
Expand All @@ -34,7 +32,7 @@ public static class SeqLoggerConfigurationExtensions
const int DefaultBatchPostingLimit = 1000;
static readonly TimeSpan DefaultPeriod = TimeSpan.FromSeconds(2);
const int DefaultQueueSizeLimit = 100000;
static ITextFormatter CreateDefaultFormatter() => new SeqCompactJsonFormatter();
static ITextFormatter CreateDefaultFormatter(IFormatProvider? formatProvider) => new SeqCompactJsonFormatter(formatProvider);

/// <summary>
/// Write log events to a <a href="https://datalust.co/seq">Seq</a> server.
Expand Down Expand Up @@ -67,6 +65,8 @@ public static class SeqLoggerConfigurationExtensions
/// durable log shipping.</param>
/// <param name="payloadFormatter">An <see cref="ITextFormatter"/> that will be used to format (newline-delimited CLEF/JSON)
/// payloads. Experimental.</param>
/// <param name="formatProvider">An <see cref="IFormatProvider"/> that will be used to render log event tokens. Does not apply if <paramref name="payloadFormatter"/> is provided.
/// If <paramref name="formatProvider"/> is provided then event messages will be rendered and included in the payload.</param>
/// <returns>Logger configuration, allowing configuration to continue.</returns>
/// <exception cref="ArgumentNullException">A required parameter is null.</exception>
public static LoggerConfiguration Seq(
Expand All @@ -83,7 +83,8 @@ public static LoggerConfiguration Seq(
HttpMessageHandler? messageHandler = null,
long? retainedInvalidPayloadsLimitBytes = null,
int queueSizeLimit = DefaultQueueSizeLimit,
ITextFormatter? payloadFormatter = null)
ITextFormatter? payloadFormatter = null,
IFormatProvider? formatProvider = null)
{
if (loggerSinkConfiguration == null) throw new ArgumentNullException(nameof(loggerSinkConfiguration));
if (serverUrl == null) throw new ArgumentNullException(nameof(serverUrl));
Expand All @@ -94,7 +95,7 @@ public static LoggerConfiguration Seq(

var defaultedPeriod = period ?? DefaultPeriod;
var controlledSwitch = new ControlledLevelSwitch(controlLevelSwitch);
var formatter = payloadFormatter ?? CreateDefaultFormatter();
var formatter = payloadFormatter ?? CreateDefaultFormatter(formatProvider);
var ingestionApi = new SeqIngestionApiClient(serverUrl, apiKey, messageHandler);

if (bufferBaseFilename == null)
Expand Down Expand Up @@ -145,6 +146,7 @@ public static LoggerConfiguration Seq(
/// <param name="messageHandler">Used to construct the HttpClient that will send the log messages to Seq.</param>
/// <param name="payloadFormatter">An <see cref="ITextFormatter"/> that will be used to format (newline-delimited CLEF/JSON)
/// payloads. Experimental.</param>
/// <param name="formatProvider">An <see cref="IFormatProvider"/> that will be used to render log event tokens.</param>
/// <returns>Logger configuration, allowing configuration to continue.</returns>
/// <exception cref="ArgumentNullException">A required parameter is null.</exception>
public static LoggerConfiguration Seq(
Expand All @@ -153,13 +155,14 @@ public static LoggerConfiguration Seq(
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
string? apiKey = null,
HttpMessageHandler? messageHandler = null,
ITextFormatter? payloadFormatter = null)
ITextFormatter? payloadFormatter = null,
IFormatProvider? formatProvider = null)
{
if (loggerAuditSinkConfiguration == null) throw new ArgumentNullException(nameof(loggerAuditSinkConfiguration));
if (serverUrl == null) throw new ArgumentNullException(nameof(serverUrl));

var ingestionApi = new SeqIngestionApiClient(serverUrl, apiKey, messageHandler);
var sink = new SeqAuditSink(ingestionApi, payloadFormatter ?? CreateDefaultFormatter());
var sink = new SeqAuditSink(ingestionApi, payloadFormatter ?? CreateDefaultFormatter(formatProvider));
return loggerAuditSinkConfiguration.Sink(sink, restrictedToMinimumLevel);
}
}
Loading

0 comments on commit 7060727

Please sign in to comment.