Skip to content

Commit

Permalink
Merge pull request #26 from serilog/dev
Browse files Browse the repository at this point in the history
3.0.0 Release
  • Loading branch information
nblumhardt authored Jun 14, 2024
2 parents 74f35ea + e21159b commit 560d9bc
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 57 deletions.
12 changes: 8 additions & 4 deletions Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if(Test-Path .\artifacts) {

$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.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "master" -and $revision -ne "local"]
$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "main" -and $revision -ne "local"]
$commitHash = $(git rev-parse --short HEAD)
$buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""]

Expand All @@ -23,9 +23,13 @@ foreach ($src in ls src/*) {

echo "build: Packaging project in $src"

& dotnet build -c Release --version-suffix=$buildSuffix /p:ContinuousIntegrationBuild=true
& dotnet pack -c Release -o ..\..\artifacts --version-suffix=$suffix --no-build
if($LASTEXITCODE -ne 0) { exit 1 }
& dotnet build -c Release --version-suffix=$buildSuffix -p:ContinuousIntegrationBuild=true
if ($suffix) {
& dotnet pack -c Release -o ..\..\artifacts --version-suffix=$suffix --no-build
} else {
& dotnet pack -c Release -o ..\..\artifacts --no-build
}
if($LASTEXITCODE -ne 0) { throw "build failed" }

Pop-Location
}
Expand Down
13 changes: 8 additions & 5 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
version: '{build}'
skip_tags: true
image: Visual Studio 2019
image: Visual Studio 2022
configuration: Release
build_script:
- ps: ./Build.ps1
test: off
artifacts:
- path: artifacts/Serilog.*.nupkg
- path: artifacts/Serilog.*.snupkg
deploy:
- provider: NuGet
api_key:
secure: 9B24CFy1l5KYjxsp8AXPx6ANkDI3KKXSqi18nCUk1kyj0mClwfNbNj0Tna4+gUC5
secure: Fh92tRIFbe1FAiyD8lTThWgAorQ1vV+eFYMlUK0iLHBBenJcy/UYc1qj6kgHvUcO
skip_symbols: true
on:
branch: /^(master|dev)$/
branch: /^(main|dev)$/
- provider: GitHub
auth_token:
secure: p4LpVhBKxGS5WqucHxFQ5c7C8cP74kbNB0Z8k9Oxx/PMaDQ1+ibmoexNqVU5ZlmX
artifact: /Serilog.*\.nupkg/
artifacts:
/Serilog.*\.nupkg/
/Serilog.*\.snupkg/
tag: v$(appveyor_build_version)
on:
branch: master
branch: main
18 changes: 10 additions & 8 deletions src/Serilog.Enrichers.Process/Enrichers/ProcessIdEnricher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ namespace Serilog.Enrichers
/// <summary>
/// Enriches log events with a ProcessId property containing the current <see cref="System.Diagnostics.Process.Id"/>.
/// </summary>
public class ProcessIdEnricher : ILogEventEnricher
sealed class ProcessIdEnricher : ILogEventEnricher
{
LogEventProperty _cachedProperty;
LogEventProperty? _cachedProperty;

/// <summary>
/// The property name added to enriched log events.
/// </summary>
public const string ProcessIdPropertyName = "ProcessId";
const string ProcessIdPropertyName = "ProcessId";

/// <summary>
/// Enrich the log event.
Expand All @@ -36,16 +36,18 @@ public class ProcessIdEnricher : ILogEventEnricher
/// <param name="propertyFactory">Factory for creating new properties to add to the event.</param>
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
{
_cachedProperty = _cachedProperty ?? propertyFactory.CreateProperty(ProcessIdPropertyName, GetProcessId());
_cachedProperty ??= propertyFactory.CreateProperty(ProcessIdPropertyName, GetProcessId());
logEvent.AddPropertyIfAbsent(_cachedProperty);
}

private static int GetProcessId()
{
using(var process = System.Diagnostics.Process.GetCurrentProcess())
{
return process.Id;
}
#if FEATURE_ENVIRONMENT_PID
return System.Environment.ProcessId;
#else
using var process = System.Diagnostics.Process.GetCurrentProcess();
return process.Id;
#endif
}
}
}
14 changes: 6 additions & 8 deletions src/Serilog.Enrichers.Process/Enrichers/ProcessNameEnricher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ namespace Serilog.Enrichers
/// <summary>
/// Enriches log events with a ProcessName property containing the current <see cref="System.Diagnostics.Process.ProcessName"/>.
/// </summary>
public class ProcessNameEnricher : ILogEventEnricher
sealed class ProcessNameEnricher : ILogEventEnricher
{
LogEventProperty _cachedProperty;
LogEventProperty? _cachedProperty;

/// <summary>
/// The property name added to enriched log events.
/// </summary>
public const string ProcessNamePropertyName = "ProcessName";
const string ProcessNamePropertyName = "ProcessName";

/// <summary>
/// Enrich the log event.
Expand All @@ -36,16 +36,14 @@ public class ProcessNameEnricher : ILogEventEnricher
/// <param name="propertyFactory">Factory for creating new properties to add to the event.</param>
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
{
_cachedProperty = _cachedProperty ?? propertyFactory.CreateProperty(ProcessNamePropertyName, GetProcessName());
_cachedProperty ??= propertyFactory.CreateProperty(ProcessNamePropertyName, GetProcessName());
logEvent.AddPropertyIfAbsent(_cachedProperty);
}

private static string GetProcessName()
{
using(var process = System.Diagnostics.Process.GetCurrentProcess())
{
return process.ProcessName;
}
using var process = System.Diagnostics.Process.GetCurrentProcess();
return process.ProcessName;
}
}
}
6 changes: 0 additions & 6 deletions src/Serilog.Enrichers.Process/Properties/AssemblyInfo.cs

This file was deleted.

37 changes: 18 additions & 19 deletions src/Serilog.Enrichers.Process/Serilog.Enrichers.Process.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@

<PropertyGroup>
<Description>The process enricher for Serilog.</Description>
<VersionPrefix>2.0.2</VersionPrefix>
<VersionPrefix>3.0.0</VersionPrefix>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<Authors>Serilog Contributors</Authors>
<TargetFrameworks>net45;netstandard1.3;netstandard2.0</TargetFrameworks>
<!-- .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>
<AssemblyName>Serilog.Enrichers.Process</AssemblyName>
<AssemblyOriginatorKeyFile>../../assets/Serilog.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
Expand All @@ -14,36 +20,29 @@
<PackageIcon>serilog-enricher-nuget.png</PackageIcon>
<PackageProjectUrl>http://serilog.net</PackageProjectUrl>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<RepositoryUrl>https://github.com/serilog/serilog-enrichers-process</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Serilog" Version="2.3.0" />
<PackageReference Include="Serilog" Version="4.0.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
<PackageReference Include="System.Diagnostics.Process" Version="4.1.0" />
</ItemGroup>
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))">
<DefineConstants>$(DefineConstants);FEATURE_ENVIRONMENT_PID</DefineConstants>
</PropertyGroup>

<ItemGroup>
<None Include="..\..\assets\serilog-enricher-nuget.png">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
<None Include="../../README.md" Pack="true" Visible="false" PackagePath="/" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;netcoreapp2.1;net46</TargetFrameworks>
<IsPackable>false</IsPackable>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT'">net462;net48</TargetFrameworks>
<TargetFrameworks>$(TargetFrameworks);net6.0;net8.0</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Serilog.Enrichers.Process\Serilog.Enrichers.Process.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit" Version="2.8.1" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ public class DelegatingSink : ILogEventSink

public DelegatingSink(Action<LogEvent> write)
{
if (write == null) throw new ArgumentNullException(nameof(write));
_write = write;
_write = write ?? throw new ArgumentNullException(nameof(write));
}

public void Emit(LogEvent logEvent)
Expand Down

0 comments on commit 560d9bc

Please sign in to comment.