Skip to content

Commit 17adba2

Browse files
authored
Merge pull request #89 from merbla/package-split
Split of Sinks to address #88
2 parents 98e8457 + dfb97e7 commit 17adba2

File tree

14 files changed

+225
-160
lines changed

14 files changed

+225
-160
lines changed

build.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ set -e
33
dotnet --info
44
dotnet restore
55

6-
for path in src/**/*.csproj; do
6+
# Until # 65 is addressed build only core package. When available move to netstandard for all packages
7+
for path in src/**/Serilog.Sinks.Splunk.csproj; do
78
dotnet build -f netstandard1.1 -c Release ${path}
89
dotnet build -f netstandard1.3 -c Release ${path}
910
done

sample/Sample/Sample.csproj

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,15 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFrameworks>netcoreapp2.0;net47</TargetFrameworks>
5+
<TargetFrameworks>netcoreapp2.0</TargetFrameworks>
66
</PropertyGroup>
77

88
<ItemGroup>
99
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.0" />
10-
</ItemGroup>
11-
12-
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">
13-
<PackageReference Include="System.Net.Http" Version="4.3.2" />
14-
</ItemGroup>
15-
16-
<ItemGroup Condition=" '$(TargetFramework)' == 'net47' ">
17-
<Reference Include="System.Net.Http" />
10+
<PackageReference Include="System.Net.Http" Version="4.3.3" />
1811
</ItemGroup>
1912

2013
<ItemGroup>
2114
<ProjectReference Include="..\..\src\Serilog.Sinks.Splunk\Serilog.Sinks.Splunk.csproj" />
2215
</ItemGroup>
23-
2416
</Project>

serilog-sinks-splunk.sln

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,16 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sample", "sample", "{1C75E4
2222
EndProject
2323
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{B9451AD8-09B9-4C09-A152-FBAE24806614}"
2424
EndProject
25-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Serilog.Sinks.Splunk", "src\Serilog.Sinks.Splunk\Serilog.Sinks.Splunk.csproj", "{32CF915C-3ECD-496C-8FDB-1214581274A6}"
25+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.Sinks.Splunk", "src\Serilog.Sinks.Splunk\Serilog.Sinks.Splunk.csproj", "{32CF915C-3ECD-496C-8FDB-1214581274A6}"
2626
EndProject
27-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Serilog.Sinks.Splunk.Tests", "test\Serilog.Sinks.Splunk.Tests\Serilog.Sinks.Splunk.Tests.csproj", "{3C2D8E01-5580-426A-BDD9-EC59CD98E618}"
27+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.Sinks.Splunk.Tests", "test\Serilog.Sinks.Splunk.Tests\Serilog.Sinks.Splunk.Tests.csproj", "{3C2D8E01-5580-426A-BDD9-EC59CD98E618}"
2828
EndProject
2929
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample", "sample\Sample\Sample.csproj", "{4A4E361D-8BBE-4DDD-9E6C-53960C2B5F5B}"
3030
EndProject
31+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.Sinks.Splunk.TCP", "src\Serilog.Sinks.TCP\Serilog.Sinks.Splunk.TCP.csproj", "{F74FCFD0-536B-4311-AA66-0BD16112D895}"
32+
EndProject
33+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.Sinks.Splunk.UDP", "src\Serilog.Sinks.UDP\Serilog.Sinks.Splunk.UDP.csproj", "{FE1504A6-5444-4B87-819C-E6F477662B7F}"
34+
EndProject
3135
Global
3236
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3337
Debug|Any CPU = Debug|Any CPU
@@ -46,6 +50,14 @@ Global
4650
{4A4E361D-8BBE-4DDD-9E6C-53960C2B5F5B}.Debug|Any CPU.Build.0 = Debug|Any CPU
4751
{4A4E361D-8BBE-4DDD-9E6C-53960C2B5F5B}.Release|Any CPU.ActiveCfg = Release|Any CPU
4852
{4A4E361D-8BBE-4DDD-9E6C-53960C2B5F5B}.Release|Any CPU.Build.0 = Release|Any CPU
53+
{F74FCFD0-536B-4311-AA66-0BD16112D895}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
54+
{F74FCFD0-536B-4311-AA66-0BD16112D895}.Debug|Any CPU.Build.0 = Debug|Any CPU
55+
{F74FCFD0-536B-4311-AA66-0BD16112D895}.Release|Any CPU.ActiveCfg = Release|Any CPU
56+
{F74FCFD0-536B-4311-AA66-0BD16112D895}.Release|Any CPU.Build.0 = Release|Any CPU
57+
{FE1504A6-5444-4B87-819C-E6F477662B7F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
58+
{FE1504A6-5444-4B87-819C-E6F477662B7F}.Debug|Any CPU.Build.0 = Debug|Any CPU
59+
{FE1504A6-5444-4B87-819C-E6F477662B7F}.Release|Any CPU.ActiveCfg = Release|Any CPU
60+
{FE1504A6-5444-4B87-819C-E6F477662B7F}.Release|Any CPU.Build.0 = Release|Any CPU
4961
EndGlobalSection
5062
GlobalSection(SolutionProperties) = preSolution
5163
HideSolutionNode = FALSE
@@ -54,5 +66,7 @@ Global
5466
{32CF915C-3ECD-496C-8FDB-1214581274A6} = {7A774CBB-A6E9-4854-B4DB-4CF860B0C1C5}
5567
{3C2D8E01-5580-426A-BDD9-EC59CD98E618} = {B9451AD8-09B9-4C09-A152-FBAE24806614}
5668
{4A4E361D-8BBE-4DDD-9E6C-53960C2B5F5B} = {1C75E4A9-4CB1-497C-AD17-B438882051A1}
69+
{F74FCFD0-536B-4311-AA66-0BD16112D895} = {7A774CBB-A6E9-4854-B4DB-4CF860B0C1C5}
70+
{FE1504A6-5444-4B87-819C-E6F477662B7F} = {7A774CBB-A6E9-4854-B4DB-4CF860B0C1C5}
5771
EndGlobalSection
5872
EndGlobal

src/Serilog.Sinks.Splunk/Serilog.Sinks.Splunk.csproj

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,25 @@
22

33
<PropertyGroup>
44
<Description>The Splunk Sink for Serilog</Description>
5-
<VersionPrefix>2.6.0</VersionPrefix>
5+
<VersionPrefix>3.0.0</VersionPrefix>
66
<Authors>Matthew Erbs, Serilog Contributors</Authors>
7-
<TargetFrameworks>net45;netstandard1.1;netstandard1.3</TargetFrameworks>
7+
<TargetFrameworks>netstandard1.1;netstandard1.3</TargetFrameworks>
88
<GenerateDocumentationFile>true</GenerateDocumentationFile>
99
<AssemblyName>Serilog.Sinks.Splunk</AssemblyName>
1010
<PackageId>Serilog.Sinks.Splunk</PackageId>
11-
<PackageTags>serilog;splunk;logging;event;collector</PackageTags>
11+
<PackageTags>serilog;splunk;logging;event;collector;hec</PackageTags>
1212
<PackageIconUrl>http://serilog.net/images/serilog-sink-nuget.png</PackageIconUrl>
1313
<PackageProjectUrl>https://github.com/serilog/serilog-sinks-splunk</PackageProjectUrl>
1414
<PackageLicenseUrl>http://www.apache.org/licenses/LICENSE-2.0</PackageLicenseUrl>
1515
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
1616
</PropertyGroup>
1717

18-
<PropertyGroup Condition=" '$(TargetFramework)' == 'net45' ">
19-
<DefineConstants>$(DefineConstants);TCP;UDP</DefineConstants>
20-
</PropertyGroup>
21-
22-
<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
23-
<PackageReference Include="Splunk.Logging.Common" Version="1.6.0" />
24-
<Reference Include="System.Net.Http" />
25-
<Reference Include="System" />
26-
<Reference Include="Microsoft.CSharp" />
27-
</ItemGroup>
28-
29-
30-
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.1' ">
31-
<PackageReference Include="System.Net.Http" Version="4.3.2" />
32-
</ItemGroup>
33-
3418
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
35-
<PackageReference Include="System.Net.Http" Version="4.3.2" />
19+
<PackageReference Include="Serilog" Version="2.6.0" />
20+
<PackageReference Include="System.Net.Http" Version="4.3.3" />
3621
</ItemGroup>
3722

3823
<ItemGroup>
39-
<PackageReference Include="Serilog" Version="2.5.0" />
4024
<PackageReference Include="Serilog.Sinks.PeriodicBatching" Version="2.1.1" />
4125
</ItemGroup>
4226

src/Serilog.Sinks.Splunk/SplunkLoggingConfigurationExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2016 Serilog Contributors
1+
// Copyright 2018 Serilog Contributors
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
4+
[assembly: AssemblyVersion("2.0.0.0")]
5+
6+
[assembly: InternalsVisibleTo("Serilog.Sinks.Splunk.Tests")]
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<Description>The Splunk TCP Sink for Serilog</Description>
5+
<VersionPrefix>1.0.0</VersionPrefix>
6+
<Authors>Matthew Erbs, Serilog Contributors</Authors>
7+
<TargetFrameworks>net45;</TargetFrameworks>
8+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
9+
<AssemblyName>Serilog.Sinks.Splunk.TCP</AssemblyName>
10+
<PackageId>Serilog.Sinks.Splunk.TCP</PackageId>
11+
<PackageTags>serilog;splunk;logging;tcp</PackageTags>
12+
<PackageIconUrl>http://serilog.net/images/serilog-sink-nuget.png</PackageIconUrl>
13+
<PackageProjectUrl>https://github.com/serilog/serilog-sinks-splunk</PackageProjectUrl>
14+
<PackageLicenseUrl>http://www.apache.org/licenses/LICENSE-2.0</PackageLicenseUrl>
15+
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
16+
</PropertyGroup>
17+
18+
<ItemGroup>
19+
<PackageReference Include="Serilog.Sinks.Splunk" Version="2.5.0" />
20+
<PackageReference Include="Splunk.Logging.Common" Version="1.6.0" />
21+
<Reference Include="System.Net.Http" />
22+
<Reference Include="System" />
23+
<Reference Include="Microsoft.CSharp" />
24+
<PackageReference Include="Serilog" Version="2.6.0" />
25+
<PackageReference Include="Serilog.Sinks.PeriodicBatching" Version="2.1.1" />
26+
</ItemGroup>
27+
28+
</Project>
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
// Copyright 2018 Serilog 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+
using System;
16+
using System.Net;
17+
using Serilog.Configuration;
18+
using Serilog.Events;
19+
using Serilog.Formatting;
20+
using Serilog.Formatting.Display;
21+
using Serilog.Sinks.Splunk;
22+
23+
namespace Serilog
24+
{
25+
/// <summary>
26+
/// Adds the WriteTo.SplunkViaEventCollector() extension method to <see cref="LoggerConfiguration"/>.
27+
/// </summary>
28+
public static class LoggerConfigurationSplunkExtensions
29+
{
30+
/// <summary>
31+
/// Adds a sink that writes log events as to a Splunk instance via TCP.
32+
/// </summary>
33+
/// <param name="loggerConfiguration">The logger config</param>
34+
/// <param name="connectionInfo"></param>
35+
/// <param name="restrictedToMinimumLevel">The minimum log event level required in order to write an event to the sink.</param>
36+
/// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
37+
/// <param name="renderTemplate">If true, the message template is rendered</param>
38+
/// <returns></returns>
39+
public static LoggerConfiguration SplunkViaTcp(
40+
this LoggerSinkConfiguration loggerConfiguration,
41+
SplunkTcpSinkConnectionInfo connectionInfo,
42+
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
43+
IFormatProvider formatProvider = null,
44+
bool renderTemplate = true)
45+
{
46+
var sink = new TcpSink(connectionInfo, formatProvider, renderTemplate);
47+
48+
return loggerConfiguration.Sink(sink, restrictedToMinimumLevel);
49+
}
50+
51+
/// <summary>
52+
/// Adds a sink that writes log events as to a Splunk instance via TCP.
53+
/// </summary>
54+
/// <param name="loggerConfiguration">The logger config</param>
55+
/// <param name="connectionInfo"></param>
56+
/// <param name="formatter">Custom formatter to use if you e.g. do not want to use the JsonFormatter.</param>
57+
/// <param name="restrictedToMinimumLevel">The minimum log event level required in order to write an event to the sink.</param>
58+
/// <returns></returns>
59+
public static LoggerConfiguration SplunkViaTcp(
60+
this LoggerSinkConfiguration loggerConfiguration,
61+
SplunkTcpSinkConnectionInfo connectionInfo,
62+
ITextFormatter formatter,
63+
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum)
64+
{
65+
var sink = new TcpSink(connectionInfo, formatter);
66+
67+
return loggerConfiguration.Sink(sink, restrictedToMinimumLevel);
68+
}
69+
70+
/// <summary>
71+
/// Adds a sink that writes log events as to a Splunk instance via TCP.
72+
/// </summary>
73+
/// <param name="loggerConfiguration">The logger config</param>
74+
/// <param name="hostAddresss">The Splunk host that is configured for UDP logging</param>
75+
/// <param name="port">The TCP port</param>
76+
/// <param name="restrictedToMinimumLevel">The minimum log event level required in order to write an event to the sink.</param>
77+
/// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
78+
/// <param name="renderTemplate">If true, the message template is rendered</param>
79+
/// <returns></returns>
80+
/// <remarks>TODO: Add link to splunk configuration and wiki</remarks>
81+
[Obsolete("Use the overload accepting a connection info object instead. This overload will be removed.", false)]
82+
public static LoggerConfiguration SplunkViaTcp(
83+
this LoggerSinkConfiguration loggerConfiguration,
84+
IPAddress hostAddresss,
85+
int port,
86+
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
87+
IFormatProvider formatProvider = null,
88+
bool renderTemplate = true)
89+
{
90+
var sink = new TcpSink(hostAddresss, port, formatProvider, renderTemplate);
91+
92+
return loggerConfiguration.Sink(sink, restrictedToMinimumLevel);
93+
}
94+
95+
/// <summary>
96+
/// Adds a sink that writes log events as to a Splunk instance via TCP.
97+
/// </summary>
98+
/// <param name="loggerConfiguration">The logger config</param>
99+
/// <param name="host">The Splunk host that is configured for UDP logging</param>
100+
/// <param name="port">The TCP port</param>
101+
/// <param name="restrictedToMinimumLevel">The minimum log event level required in order to write an event to the sink.</param>
102+
/// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
103+
/// <param name="renderTemplate">If ture, the message template is rendered</param>
104+
/// <returns></returns>
105+
/// <remarks>TODO: Add link to splunk configuration and wiki</remarks>
106+
[Obsolete("Use the overload accepting a connection info object instead. This overload will be removed.", false)]
107+
public static LoggerConfiguration SplunkViaTcp(
108+
this LoggerSinkConfiguration loggerConfiguration,
109+
string host,
110+
int port,
111+
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
112+
IFormatProvider formatProvider = null,
113+
bool renderTemplate = true)
114+
{
115+
var sink = new TcpSink(host, port, formatProvider, renderTemplate);
116+
117+
return loggerConfiguration.Sink(sink, restrictedToMinimumLevel);
118+
}
119+
}
120+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
4+
[assembly: AssemblyVersion("2.0.0.0")]
5+
6+
[assembly: InternalsVisibleTo("Serilog.Sinks.Splunk.Tests")]

0 commit comments

Comments
 (0)