Skip to content

Commit

Permalink
Moved enrichers to new projects. Serilog.Enrichers.Environment contai…
Browse files Browse the repository at this point in the history
…ns UserName and Machine Name. Serilog.Erichers.Thread contains ThreadId. Serilog.Enrichers.Process contains ProcessId.
  • Loading branch information
merbla committed Feb 19, 2016
1 parent afa17f1 commit 69cc2e3
Show file tree
Hide file tree
Showing 18 changed files with 304 additions and 65 deletions.
21 changes: 21 additions & 0 deletions Serilog.sln
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Serilog.Sinks.Trace", "src\
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Serilog.Settings.AppSettings", "src\Serilog.Settings.AppSettings\Serilog.Settings.AppSettings.xproj", "{0D9F37E3-2CB4-4C0D-A307-32BB71DEFDD4}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Serilog.Enrichers.Environment", "src\Serilog.Enrichers.Environment\Serilog.Enrichers.Environment.xproj", "{B884782D-6C07-4779-9074-D97F622799A9}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Serilog.Enrichers.Process", "src\Serilog.Enrichers.Process\Serilog.Enrichers.Process.xproj", "{2312A998-5E53-4355-9CB6-6014252B3E88}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Serilog.Enrichers.Thread", "src\Serilog.Enrichers.Thread\Serilog.Enrichers.Thread.xproj", "{E0BD3797-55A5-4E8C-8DE7-8487BEB75914}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -89,6 +95,18 @@ Global
{0D9F37E3-2CB4-4C0D-A307-32BB71DEFDD4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0D9F37E3-2CB4-4C0D-A307-32BB71DEFDD4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0D9F37E3-2CB4-4C0D-A307-32BB71DEFDD4}.Release|Any CPU.Build.0 = Release|Any CPU
{B884782D-6C07-4779-9074-D97F622799A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B884782D-6C07-4779-9074-D97F622799A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B884782D-6C07-4779-9074-D97F622799A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B884782D-6C07-4779-9074-D97F622799A9}.Release|Any CPU.Build.0 = Release|Any CPU
{2312A998-5E53-4355-9CB6-6014252B3E88}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2312A998-5E53-4355-9CB6-6014252B3E88}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2312A998-5E53-4355-9CB6-6014252B3E88}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2312A998-5E53-4355-9CB6-6014252B3E88}.Release|Any CPU.Build.0 = Release|Any CPU
{E0BD3797-55A5-4E8C-8DE7-8487BEB75914}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E0BD3797-55A5-4E8C-8DE7-8487BEB75914}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E0BD3797-55A5-4E8C-8DE7-8487BEB75914}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E0BD3797-55A5-4E8C-8DE7-8487BEB75914}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -105,5 +123,8 @@ Global
{E85ABEC7-9B4C-432C-9A04-AC5BE9205D9F} = {037440DE-440B-4129-9F7A-09B42D00397E}
{8849C92D-2120-4C82-8226-22DF40195237} = {037440DE-440B-4129-9F7A-09B42D00397E}
{0D9F37E3-2CB4-4C0D-A307-32BB71DEFDD4} = {037440DE-440B-4129-9F7A-09B42D00397E}
{B884782D-6C07-4779-9074-D97F622799A9} = {037440DE-440B-4129-9F7A-09B42D00397E}
{2312A998-5E53-4355-9CB6-6014252B3E88} = {037440DE-440B-4129-9F7A-09B42D00397E}
{E0BD3797-55A5-4E8C-8DE7-8487BEB75914} = {037440DE-440B-4129-9F7A-09B42D00397E}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2013-2015 Serilog Contributors
// Copyright 2013-2016 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2013-2015 Serilog Contributors
// Copyright 2013-2016 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -11,12 +11,12 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#if !DOTNET5_1


using System;
using Serilog.Core;
using Serilog.Events;
using System.Runtime.InteropServices;

namespace Serilog.Enrichers
{
Expand Down Expand Up @@ -47,5 +47,4 @@ public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
logEvent.AddPropertyIfAbsent(_cachedProperty);
}
}
}
#endif
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright 2013-2016 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using Serilog.Configuration;
using Serilog.Enrichers;

namespace Serilog
{
public static class EnvironmentLoggerConfigurationExtensions
{
/// <summary>
/// Enrich log events with a MachineName property containing the current <see cref="Environment.MachineName"/>.
/// </summary>
/// <param name="enrichmentConfiguration">Logger enrichment configuration.</param>
/// <returns>Configuration object allowing method chaining.</returns>
public static LoggerConfiguration WithMachineName(
this LoggerEnrichmentConfiguration enrichmentConfiguration)
{
if (enrichmentConfiguration == null) throw new ArgumentNullException(nameof(enrichmentConfiguration));
return enrichmentConfiguration.With<MachineNameEnricher>();
}

/// <summary>
/// Enriches log events with an EnvironmentUserName property containing [<see cref="Environment.UserDomainName"/>\]<see cref="Environment.UserName"/>.
/// </summary>
/// <param name="enrichmentConfiguration">Logger enrichment configuration.</param>
/// <returns>Configuration object allowing method chaining.</returns>
public static LoggerConfiguration WithEnvironmentUserName(
this LoggerEnrichmentConfiguration enrichmentConfiguration)
{
if (enrichmentConfiguration == null) throw new ArgumentNullException(nameof(enrichmentConfiguration));
return enrichmentConfiguration.With<EnvironmentUserNameEnricher>();
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>b884782d-6c07-4779-9074-d97f622799a9</ProjectGuid>
<RootNamespace>Serilog</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
24 changes: 24 additions & 0 deletions src/Serilog.Enrichers.Environment/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"version": "2.0.0-beta-*",
"description": "The enviornment enrichers for Serilog.",
"authors": [ "Serilog Contributors" ],
"tags": [ "serilog", "machine", "enricher" ],
"projectUrl": "http://serilog.net",
"licenseUrl": "http://www.apache.org/licenses/LICENSE-2.0",
"iconUrl": "http://serilog.net/images/serilog-extension-nuget.png",
"dependencies": {
"Serilog": { "target": "project" }
},
"compilationOptions": {
"keyFile": "../../assets/Serilog.snk"
},
"frameworks": {
"net45": {
},
"dotnet5.4": {
"dependencies": {
"System.Runtime.Extensions": "4.0.11-beta-23516"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#if PROCESS


using Serilog.Core;
using Serilog.Events;

Expand Down Expand Up @@ -42,5 +40,4 @@ public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
logEvent.AddPropertyIfAbsent(_cachedProperty);
}
}
}
#endif
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright 2013-2016 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.


using System;
using System.Diagnostics;
using Serilog.Configuration;
using Serilog.Enrichers;

namespace Serilog
{
public static class ProcessLoggerConfigurationExtensions
{
/// <summary>
/// Enrich log events with a ProcessId property containing the current <see cref="Process.Id"/>.
/// </summary>
/// <param name="enrichmentConfiguration">Logger enrichment configuration.</param>
/// <returns>Configuration object allowing method chaining.</returns>
public static LoggerConfiguration WithProcessId(
this LoggerEnrichmentConfiguration enrichmentConfiguration)
{
if (enrichmentConfiguration == null) throw new ArgumentNullException(nameof(enrichmentConfiguration));
return enrichmentConfiguration.With<ProcessIdEnricher>();
}
}
}
18 changes: 18 additions & 0 deletions src/Serilog.Enrichers.Process/Serilog.Enrichers.Process.xproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>2312a998-5e53-4355-9cb6-6014252b3e88</ProjectGuid>
<RootNamespace>Serilog</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
30 changes: 30 additions & 0 deletions src/Serilog.Enrichers.Process/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"version": "2.0.0-beta-*",
"description": "The process enricher for Serilog.",
"authors": [ "Serilog Contributors" ],
"tags": [ "serilog", "process", "enricher" ],
"projectUrl": "http://serilog.net",
"licenseUrl": "http://www.apache.org/licenses/LICENSE-2.0",
"iconUrl": "http://serilog.net/images/serilog-extension-nuget.png",
"dependencies": {
"Serilog": { "target": "project" }
},
"compilationOptions": {
"keyFile": "../../assets/Serilog.snk"
},
"frameworks": {
"net45": {
},
"dotnet5.1": {
"dependencies": {
"System.Diagnostics.Process": "4.1.0-beta-23409"
}
},
"dotnet5.4": {
"dependencies": {
"System.Diagnostics.Process": "4.1.0-beta-23516"
}
}

}
}
File renamed without changes.
18 changes: 18 additions & 0 deletions src/Serilog.Enrichers.Thread/Serilog.Enrichers.Thread.xproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>e0bd3797-55a5-4e8c-8de7-8487beb75914</ProjectGuid>
<RootNamespace>Serilog</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright 2013-2016 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.


using System;
using System.Threading;
using Serilog.Configuration;
using Serilog.Enrichers;

namespace Serilog
{
public static class ThreadLoggerConfigurationExtensions
{

/// <summary>
/// Enrich log events with a ThreadId property containing the current <see cref="Thread.ManagedThreadId"/>.
/// </summary>
/// <param name="enrichmentConfiguration">Logger enrichment configuration.</param>
/// <returns>Configuration object allowing method chaining.</returns>
/// <exception cref="ArgumentNullException"></exception>
public static LoggerConfiguration WithThreadId(
this LoggerEnrichmentConfiguration enrichmentConfiguration)
{
if (enrichmentConfiguration == null) throw new ArgumentNullException(nameof(enrichmentConfiguration));
return enrichmentConfiguration.With<ThreadIdEnricher>();
}
}
}
21 changes: 21 additions & 0 deletions src/Serilog.Enrichers.Thread/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"version": "2.0.0-beta-*",
"description": "The thread enricher for Serilog.",
"authors": [ "Serilog Contributors" ],
"tags": [ "serilog", "thread", "enricher" ],
"projectUrl": "http://serilog.net",
"licenseUrl": "http://www.apache.org/licenses/LICENSE-2.0",
"iconUrl": "http://serilog.net/images/serilog-extension-nuget.png",
"dependencies": {
"Serilog": { "target": "project" }
},
"compilationOptions": {
"keyFile": "../../assets/Serilog.snk"
},
"frameworks": {
"net45": {
},
"dotnet5.1": {
}
}
}
Loading

0 comments on commit 69cc2e3

Please sign in to comment.