Skip to content

Commit 74f35ea

Browse files
authored
Merge pull request #18 from serilog/dev
2.0.2 Release
2 parents 80a9c16 + a4e3b54 commit 74f35ea

17 files changed

+219
-76
lines changed

Build.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ foreach ($src in ls src/*) {
2323

2424
echo "build: Packaging project in $src"
2525

26-
& dotnet build -c Release --version-suffix=$buildSuffix
26+
& dotnet build -c Release --version-suffix=$buildSuffix /p:ContinuousIntegrationBuild=true
2727
& dotnet pack -c Release -o ..\..\artifacts --version-suffix=$suffix --no-build
2828
if($LASTEXITCODE -ne 0) { exit 1 }
2929

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
The process enricher for Serilog.
44

5-
[![Build status](https://ci.appveyor.com/api/projects/status/ihq58voxyfwfanyg?svg=true)](https://ci.appveyor.com/project/serilog/serilog-enrichers-process) [![NuGet Version](http://img.shields.io/nuget/v/Serilog.Enrichers.Process.svg?style=flat)](https://www.nuget.org/packages/Serilog.Enricher.Process/)
5+
[![Build status](https://ci.appveyor.com/api/projects/status/ihq58voxyfwfanyg?svg=true)](https://ci.appveyor.com/project/serilog/serilog-enrichers-process) [![NuGet Version](http://img.shields.io/nuget/v/Serilog.Enrichers.Process.svg?style=flat)](https://www.nuget.org/packages/Serilog.Enrichers.Process/)
66

77

88
To use the enricher, first install the NuGet package:
@@ -11,6 +11,16 @@ To use the enricher, first install the NuGet package:
1111
Install-Package Serilog.Enrichers.Process
1212
```
1313

14+
Then add `Enrich.WithProcessId()` and/or `.WithProcessName()` to the `LoggerConfiguration()`:
15+
16+
```csharp
17+
Log.Logger = new LoggerConfiguration()
18+
.WriteTo.Console()
19+
.Enrich.WithProcessId()
20+
.Enrich.WithProcessName()
21+
.CreateLogger();
22+
```
23+
1424
* [Documentation](https://github.com/serilog/serilog/wiki)
1525

1626
Copyright © 2016 Serilog Contributors - Provided under the [Apache License, Version 2.0](http://apache.org/licenses/LICENSE-2.0.html).

appveyor.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
version: '{build}'
22
skip_tags: true
3-
image: Visual Studio 2015
3+
image: Visual Studio 2019
44
configuration: Release
5-
install:
6-
- ps: mkdir -Force ".\build\" | Out-Null
7-
- ps: Invoke-WebRequest "https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0-preview2/scripts/obtain/dotnet-install.ps1" -OutFile ".\build\installcli.ps1"
8-
- ps: $env:DOTNET_INSTALL_DIR = "$pwd\.dotnetcli"
9-
- ps: '& .\build\installcli.ps1 -InstallDir "$env:DOTNET_INSTALL_DIR" -NoPath -Version 1.0.0-preview2-003121'
10-
- ps: $env:Path = "$env:DOTNET_INSTALL_DIR;$env:Path"
115
build_script:
126
- ps: ./Build.ps1
137
test: off
@@ -16,7 +10,7 @@ artifacts:
1610
deploy:
1711
- provider: NuGet
1812
api_key:
19-
secure: nvZ/z+pMS91b3kG4DgfES5AcmwwGoBYQxr9kp4XiJHj25SAlgdIxFx++1N0lFH2x
13+
secure: 9B24CFy1l5KYjxsp8AXPx6ANkDI3KKXSqi18nCUk1kyj0mClwfNbNj0Tna4+gUC5
2014
skip_symbols: true
2115
on:
2216
branch: /^(master|dev)$/

assets/serilog-enricher-nuget.png

21.1 KB
Loading

global.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

serilog-enrichers-process.sln

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,47 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 14
4-
VisualStudioVersion = 14.0.24720.0
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.30608.117
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{037440DE-440B-4129-9F7A-09B42D00397E}"
77
EndProject
88
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "assets", "assets", "{E9D1B5E1-DEB9-4A04-8BAB-24EC7240ADAF}"
99
ProjectSection(SolutionItems) = preProject
1010
Build.ps1 = Build.ps1
11-
global.json = global.json
1211
NuGet.Config = NuGet.Config
1312
README.md = README.md
1413
assets\Serilog.snk = assets\Serilog.snk
1514
EndProjectSection
1615
EndProject
17-
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Serilog.Enrichers.Process", "src\Serilog.Enrichers.Process\Serilog.Enrichers.Process.xproj", "{2312A998-5E53-4355-9CB6-6014252B3E88}"
16+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Serilog.Enrichers.Process", "src\Serilog.Enrichers.Process\Serilog.Enrichers.Process.csproj", "{E950BED9-A953-4555-9159-B40ABDE7DC90}"
17+
EndProject
18+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Serilog.Enrichers.Process.Tests", "test\Serilog.Enrichers.Process.Tests\Serilog.Enrichers.Process.Tests.csproj", "{27336067-0A49-4053-9A57-76510C8D9097}"
19+
EndProject
20+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{ACD52C07-EC24-4A6D-9DE4-653A6A89F74D}"
1821
EndProject
1922
Global
2023
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2124
Debug|Any CPU = Debug|Any CPU
2225
Release|Any CPU = Release|Any CPU
2326
EndGlobalSection
2427
GlobalSection(ProjectConfigurationPlatforms) = postSolution
25-
{2312A998-5E53-4355-9CB6-6014252B3E88}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
26-
{2312A998-5E53-4355-9CB6-6014252B3E88}.Debug|Any CPU.Build.0 = Debug|Any CPU
27-
{2312A998-5E53-4355-9CB6-6014252B3E88}.Release|Any CPU.ActiveCfg = Release|Any CPU
28-
{2312A998-5E53-4355-9CB6-6014252B3E88}.Release|Any CPU.Build.0 = Release|Any CPU
28+
{E950BED9-A953-4555-9159-B40ABDE7DC90}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29+
{E950BED9-A953-4555-9159-B40ABDE7DC90}.Debug|Any CPU.Build.0 = Debug|Any CPU
30+
{E950BED9-A953-4555-9159-B40ABDE7DC90}.Release|Any CPU.ActiveCfg = Release|Any CPU
31+
{E950BED9-A953-4555-9159-B40ABDE7DC90}.Release|Any CPU.Build.0 = Release|Any CPU
32+
{27336067-0A49-4053-9A57-76510C8D9097}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33+
{27336067-0A49-4053-9A57-76510C8D9097}.Debug|Any CPU.Build.0 = Debug|Any CPU
34+
{27336067-0A49-4053-9A57-76510C8D9097}.Release|Any CPU.ActiveCfg = Release|Any CPU
35+
{27336067-0A49-4053-9A57-76510C8D9097}.Release|Any CPU.Build.0 = Release|Any CPU
2936
EndGlobalSection
3037
GlobalSection(SolutionProperties) = preSolution
3138
HideSolutionNode = FALSE
3239
EndGlobalSection
3340
GlobalSection(NestedProjects) = preSolution
34-
{2312A998-5E53-4355-9CB6-6014252B3E88} = {037440DE-440B-4129-9F7A-09B42D00397E}
41+
{E950BED9-A953-4555-9159-B40ABDE7DC90} = {037440DE-440B-4129-9F7A-09B42D00397E}
42+
{27336067-0A49-4053-9A57-76510C8D9097} = {ACD52C07-EC24-4A6D-9DE4-653A6A89F74D}
43+
EndGlobalSection
44+
GlobalSection(ExtensibilityGlobals) = postSolution
45+
SolutionGuid = {9BEC8B70-CA11-4400-AEAE-B0EAE15E933B}
3546
EndGlobalSection
3647
EndGlobal

src/Serilog.Enrichers.Process/Enrichers/ProcessIdEnricher.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,16 @@ public class ProcessIdEnricher : ILogEventEnricher
3636
/// <param name="propertyFactory">Factory for creating new properties to add to the event.</param>
3737
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
3838
{
39-
_cachedProperty = _cachedProperty ?? propertyFactory.CreateProperty(ProcessIdPropertyName, System.Diagnostics.Process.GetCurrentProcess().Id);
39+
_cachedProperty = _cachedProperty ?? propertyFactory.CreateProperty(ProcessIdPropertyName, GetProcessId());
4040
logEvent.AddPropertyIfAbsent(_cachedProperty);
4141
}
42+
43+
private static int GetProcessId()
44+
{
45+
using(var process = System.Diagnostics.Process.GetCurrentProcess())
46+
{
47+
return process.Id;
48+
}
49+
}
4250
}
4351
}

src/Serilog.Enrichers.Process/Enrichers/ProcessNameEnricher.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,16 @@ public class ProcessNameEnricher : ILogEventEnricher
3636
/// <param name="propertyFactory">Factory for creating new properties to add to the event.</param>
3737
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
3838
{
39-
_cachedProperty = _cachedProperty ?? propertyFactory.CreateProperty(ProcessNamePropertyName, System.Diagnostics.Process.GetCurrentProcess().ProcessName);
39+
_cachedProperty = _cachedProperty ?? propertyFactory.CreateProperty(ProcessNamePropertyName, GetProcessName());
4040
logEvent.AddPropertyIfAbsent(_cachedProperty);
4141
}
42+
43+
private static string GetProcessName()
44+
{
45+
using(var process = System.Diagnostics.Process.GetCurrentProcess())
46+
{
47+
return process.ProcessName;
48+
}
49+
}
4250
}
4351
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<Description>The process enricher for Serilog.</Description>
5+
<VersionPrefix>2.0.2</VersionPrefix>
6+
<Authors>Serilog Contributors</Authors>
7+
<TargetFrameworks>net45;netstandard1.3;netstandard2.0</TargetFrameworks>
8+
<AssemblyName>Serilog.Enrichers.Process</AssemblyName>
9+
<AssemblyOriginatorKeyFile>../../assets/Serilog.snk</AssemblyOriginatorKeyFile>
10+
<SignAssembly>true</SignAssembly>
11+
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
12+
<PackageId>Serilog.Enrichers.Process</PackageId>
13+
<PackageTags>serilog;process;enricher</PackageTags>
14+
<PackageIcon>serilog-enricher-nuget.png</PackageIcon>
15+
<PackageProjectUrl>http://serilog.net</PackageProjectUrl>
16+
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
17+
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
18+
<RepositoryUrl>https://github.com/serilog/serilog-enrichers-process</RepositoryUrl>
19+
<RepositoryType>git</RepositoryType>
20+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
21+
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
22+
<EmbedUntrackedSources>true</EmbedUntrackedSources>
23+
</PropertyGroup>
24+
25+
<ItemGroup>
26+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0">
27+
<PrivateAssets>all</PrivateAssets>
28+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
29+
</PackageReference>
30+
<PackageReference Include="Serilog" Version="2.3.0" />
31+
</ItemGroup>
32+
33+
<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
34+
<Reference Include="System" />
35+
<Reference Include="Microsoft.CSharp" />
36+
</ItemGroup>
37+
38+
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
39+
<PackageReference Include="System.Diagnostics.Process" Version="4.1.0" />
40+
</ItemGroup>
41+
42+
<ItemGroup>
43+
<None Include="..\..\assets\serilog-enricher-nuget.png">
44+
<Pack>True</Pack>
45+
<PackagePath></PackagePath>
46+
</None>
47+
</ItemGroup>
48+
49+
</Project>

src/Serilog.Enrichers.Process/Serilog.Enrichers.Process.xproj

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)