Skip to content

Commit 1b378bf

Browse files
Initial version of Serilog.Enrichers.GlobalLogContext
1 parent c1ae65a commit 1b378bf

22 files changed

+1195
-0
lines changed

Directory.Build.props

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Project>
2+
3+
<PropertyGroup>
4+
<LangVersion>latest</LangVersion>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<SourceRoot Include="$(MSBuildThisFileDirectory)/"/>
9+
</ItemGroup>
10+
11+
</Project>

asset/Serilog.snk

596 Bytes
Binary file not shown.
21.1 KB
Loading

global.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"sdk": {
3+
"allowPrerelease": true,
4+
"version": "5.0.100",
5+
"rollForward": "latestMajor"
6+
}
7+
}

nuget.config

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<packageSources>
4+
<clear />
5+
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
6+
</packageSources>
7+
<disabledPackageSources>
8+
<clear />
9+
</disabledPackageSources>
10+
<fallbackPackageFolders>
11+
<clear />
12+
</fallbackPackageFolders>
13+
</configuration>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFrameworks>net5.0;netstandard2.0;net45</TargetFrameworks>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<PackageReference Include="Serilog" Version="2.10.0" />
10+
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.0" />
11+
</ItemGroup>
12+
13+
<ItemGroup>
14+
<ProjectReference Include="..\..\src\Serilog.Enrichers.GlobalLogContext\Serilog.Enrichers.GlobalLogContext.csproj" />
15+
</ItemGroup>
16+
17+
</Project>

sample/ConsoleSample/Program.cs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#region Copyright 2021 C. Augusto Proiete & Contributors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
//
15+
#endregion
16+
17+
using Serilog;
18+
using Serilog.Context;
19+
20+
namespace ConsoleSample
21+
{
22+
class Program
23+
{
24+
static void Main(string[] args)
25+
{
26+
Log.Logger = new LoggerConfiguration()
27+
.WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj} {Properties}{NewLine}{Exception}")
28+
.Enrich.FromGlobalLogContext()
29+
.CreateLogger();
30+
31+
try
32+
{
33+
GlobalLogContext.PushProperty("A", 1);
34+
35+
Log.Information("Carries property A = 1");
36+
37+
using (GlobalLogContext.PushProperty("A", 2))
38+
using (GlobalLogContext.PushProperty("B", 1))
39+
{
40+
Log.Information("Carries A = 2 and B = 1");
41+
}
42+
43+
Log.Information("Carries property A = 1, again");
44+
}
45+
finally
46+
{
47+
Log.CloseAndFlush();
48+
}
49+
}
50+
}
51+
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.31402.337
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{3F07477D-F01B-488D-91E6-3378AEB6FDFC}"
7+
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{4F82E83B-D515-4CB4-AF3A-C9F2AE1ABB27}"
9+
EndProject
10+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sample", "sample", "{7582B42B-F938-4597-9584-90DBE740EE7C}"
11+
EndProject
12+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleSample", "sample\ConsoleSample\ConsoleSample.csproj", "{BF448ED2-74AA-4EA9-A2FA-EF7EFFB19B18}"
13+
EndProject
14+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "asset", "asset", "{C4E14FD5-D29D-43F6-B60D-3ED7F09C3DE9}"
15+
ProjectSection(SolutionItems) = preProject
16+
.editorconfig = .editorconfig
17+
.gitattributes = .gitattributes
18+
.gitignore = .gitignore
19+
build.cake = build.cake
20+
build.cmd = build.cmd
21+
build.ps1 = build.ps1
22+
build.sh = build.sh
23+
cake.config = cake.config
24+
CHANGES.md = CHANGES.md
25+
CODEOWNERS = CODEOWNERS
26+
Directory.Build.props = Directory.Build.props
27+
global.json = global.json
28+
nuget.config = nuget.config
29+
README.md = README.md
30+
EndProjectSection
31+
EndProject
32+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Serilog.Enrichers.GlobalLogContext", "src\Serilog.Enrichers.GlobalLogContext\Serilog.Enrichers.GlobalLogContext.csproj", "{11508E91-6A43-41CB-9F2E-4B81C1A103D1}"
33+
EndProject
34+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Serilog.Enrichers.GlobalLogContext.Tests", "test\Serilog.Enrichers.GlobalLogContext.Tests\Serilog.Enrichers.GlobalLogContext.Tests.csproj", "{766D4CC3-C4FF-4151-819A-75BCF54D7BAA}"
35+
EndProject
36+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{5D1321D4-F4E7-4BD3-99CE-C6025C0169C8}"
37+
ProjectSection(SolutionItems) = preProject
38+
.github\dependabot.yml = .github\dependabot.yml
39+
.github\FUNDING.yml = .github\FUNDING.yml
40+
EndProjectSection
41+
EndProject
42+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{D9A2B90B-2BFE-4B49-9221-22923F9CBE78}"
43+
ProjectSection(SolutionItems) = preProject
44+
.github\workflows\ci.yml = .github\workflows\ci.yml
45+
.github\workflows\dependabot-cake.yml = .github\workflows\dependabot-cake.yml
46+
EndProjectSection
47+
EndProject
48+
Global
49+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
50+
Debug|Any CPU = Debug|Any CPU
51+
Release|Any CPU = Release|Any CPU
52+
EndGlobalSection
53+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
54+
{BF448ED2-74AA-4EA9-A2FA-EF7EFFB19B18}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
55+
{BF448ED2-74AA-4EA9-A2FA-EF7EFFB19B18}.Debug|Any CPU.Build.0 = Debug|Any CPU
56+
{BF448ED2-74AA-4EA9-A2FA-EF7EFFB19B18}.Release|Any CPU.ActiveCfg = Release|Any CPU
57+
{BF448ED2-74AA-4EA9-A2FA-EF7EFFB19B18}.Release|Any CPU.Build.0 = Release|Any CPU
58+
{11508E91-6A43-41CB-9F2E-4B81C1A103D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
59+
{11508E91-6A43-41CB-9F2E-4B81C1A103D1}.Debug|Any CPU.Build.0 = Debug|Any CPU
60+
{11508E91-6A43-41CB-9F2E-4B81C1A103D1}.Release|Any CPU.ActiveCfg = Release|Any CPU
61+
{11508E91-6A43-41CB-9F2E-4B81C1A103D1}.Release|Any CPU.Build.0 = Release|Any CPU
62+
{766D4CC3-C4FF-4151-819A-75BCF54D7BAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
63+
{766D4CC3-C4FF-4151-819A-75BCF54D7BAA}.Debug|Any CPU.Build.0 = Debug|Any CPU
64+
{766D4CC3-C4FF-4151-819A-75BCF54D7BAA}.Release|Any CPU.ActiveCfg = Release|Any CPU
65+
{766D4CC3-C4FF-4151-819A-75BCF54D7BAA}.Release|Any CPU.Build.0 = Release|Any CPU
66+
EndGlobalSection
67+
GlobalSection(SolutionProperties) = preSolution
68+
HideSolutionNode = FALSE
69+
EndGlobalSection
70+
GlobalSection(NestedProjects) = preSolution
71+
{BF448ED2-74AA-4EA9-A2FA-EF7EFFB19B18} = {7582B42B-F938-4597-9584-90DBE740EE7C}
72+
{11508E91-6A43-41CB-9F2E-4B81C1A103D1} = {3F07477D-F01B-488D-91E6-3378AEB6FDFC}
73+
{766D4CC3-C4FF-4151-819A-75BCF54D7BAA} = {4F82E83B-D515-4CB4-AF3A-C9F2AE1ABB27}
74+
{5D1321D4-F4E7-4BD3-99CE-C6025C0169C8} = {C4E14FD5-D29D-43F6-B60D-3ED7F09C3DE9}
75+
{D9A2B90B-2BFE-4B49-9221-22923F9CBE78} = {5D1321D4-F4E7-4BD3-99CE-C6025C0169C8}
76+
EndGlobalSection
77+
GlobalSection(ExtensibilityGlobals) = postSolution
78+
SolutionGuid = {D0F08AD6-9632-4B75-949D-87EBCB4B115A}
79+
EndGlobalSection
80+
EndGlobal
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2+
<s:Int64 x:Key="/Default/CodeEditing/NullCheckPatterns/PatternTypeNamesToPriority/=JetBrains_002EReSharper_002EFeature_002EServices_002ECSharp_002ENullChecking_002EIfThenThrowPattern/@EntryIndexedValue">1000</s:Int64>
3+
<s:Int64 x:Key="/Default/CodeEditing/NullCheckPatterns/PatternTypeNamesToPriority/=JetBrains_002EReSharper_002EFeature_002EServices_002ECSharp_002ENullChecking_002EPatternMatchingIfThenThrowPattern/@EntryIndexedValue">3000</s:Int64>
4+
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArgumentsStyleAnonymousFunction/@EntryIndexedValue">DO_NOT_SHOW</s:String>
5+
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArgumentsStyleLiteral/@EntryIndexedValue">DO_NOT_SHOW</s:String>
6+
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArgumentsStyleNamedExpression/@EntryIndexedValue">DO_NOT_SHOW</s:String>
7+
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArgumentsStyleStringLiteral/@EntryIndexedValue">DO_NOT_SHOW</s:String>
8+
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeTrailingCommaInMultilineLists/@EntryIndexedValue">DO_NOT_SHOW</s:String>
9+
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=CommentTypo/@EntryIndexedValue">DO_NOT_SHOW</s:String>
10+
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=MarkupAttributeTypo/@EntryIndexedValue">DO_NOT_SHOW</s:String>
11+
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=MarkupTextTypo/@EntryIndexedValue">DO_NOT_SHOW</s:String>
12+
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantAnonymousTypePropertyName/@EntryIndexedValue">DO_NOT_SHOW</s:String>
13+
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=StringLiteralTypo/@EntryIndexedValue">DO_NOT_SHOW</s:String>
14+
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticReadonly/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /&gt;</s:String></wpf:ResourceDictionary>

0 commit comments

Comments
 (0)