Skip to content

Commit 8348803

Browse files
committed
Merge pull request #1 from merbla/master
Added existing code base from Serilog
2 parents fd93063 + 563663e commit 8348803

20 files changed

+1641
-2
lines changed

Build.ps1

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
param(
2+
[String] $majorMinor = "0.0", # 2.0
3+
[String] $patch = "0", # $env:APPVEYOR_BUILD_VERSION
4+
[String] $customLogger = "", # C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll
5+
[Switch] $notouch
6+
)
7+
8+
function Set-AssemblyVersions($informational, $assembly)
9+
{
10+
(Get-Content assets/CommonAssemblyInfo.cs) |
11+
ForEach-Object { $_ -replace """1.0.0.0""", """$assembly""" } |
12+
ForEach-Object { $_ -replace """1.0.0""", """$informational""" } |
13+
ForEach-Object { $_ -replace """1.1.1.1""", """$($informational).0""" } |
14+
Set-Content assets/CommonAssemblyInfo.cs
15+
}
16+
17+
function Install-NuGetPackages()
18+
{
19+
nuget restore serilog-sinks-splunk.sln
20+
}
21+
22+
function Invoke-MSBuild($solution, $customLogger)
23+
{
24+
if ($customLogger)
25+
{
26+
msbuild "$solution" /verbosity:minimal /p:Configuration=Release /logger:"$customLogger"
27+
}
28+
else
29+
{
30+
msbuild "$solution" /verbosity:minimal /p:Configuration=Release
31+
}
32+
}
33+
34+
function Invoke-NuGetPackProj($csproj)
35+
{
36+
nuget pack -Prop Configuration=Release -Symbols $csproj
37+
}
38+
39+
function Invoke-NuGetPackSpec($nuspec, $version)
40+
{
41+
nuget pack $nuspec -Version $version -OutputDirectory ..\..\
42+
}
43+
44+
function Invoke-NuGetPack($version)
45+
{
46+
ls src/**/*.csproj |
47+
Where-Object { -not ($_.Name -like "*net40*") } |
48+
ForEach-Object { Invoke-NuGetPackProj $_ }
49+
}
50+
51+
function Invoke-Build($majorMinor, $patch, $customLogger, $notouch)
52+
{
53+
$package="$majorMinor.$patch"
54+
55+
Write-Output "Building Serilog.Sinks.Splunk $package"
56+
57+
if (-not $notouch)
58+
{
59+
$assembly = "$majorMinor.0.0"
60+
61+
Write-Output "Assembly version will be set to $assembly"
62+
Set-AssemblyVersions $package $assembly
63+
}
64+
65+
Install-NuGetPackages
66+
67+
Invoke-MSBuild "serilog-sinks-splunk.sln" $customLogger
68+
69+
Invoke-NuGetPack $package
70+
}
71+
72+
$ErrorActionPreference = "Stop"
73+
Invoke-Build $majorMinor $patch $customLogger $notouch

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2.0.0
2+
* Moved the Application Insights sink from its [original location](https://github.com/serilog/serilog)

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
# seriog-sinks-splunk
2-
A Serilog sink that writes to Splunk
1+
# serilog-sinks-applicationinsights
2+
3+
[![Build status](https://ci.appveyor.com/api/projects/status/ccgd7k98kbmifl5v/branch/master?svg=true)](https://ci.appveyor.com/project/serilog/serilog-sinks-applicationinsights/branch/master)
4+
5+
A sink for Serilog that writes events to Azure Application Insights. Moved from the [main Serilog repository](https://github.com/serilog/serilog) for independent versioning. Published to [NuGet](http://www.nuget.org/packages/serilog.sinks.applicationinsights).

Serilog.sln.DotSettings

Lines changed: 559 additions & 0 deletions
Large diffs are not rendered by default.

assets/CommonAssemblyInfo.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
using System.Reflection;
2+
3+
[assembly: AssemblyVersion("1.0.0.0")]
4+
[assembly: AssemblyFileVersion("1.1.1.1")]
5+
[assembly: AssemblyInformationalVersion("1.0.0")]

assets/Serilog.snk

596 Bytes
Binary file not shown.

serilog-sinks-splunk.sln

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 2013
4+
VisualStudioVersion = 12.0.31101.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.Sinks.Splunk", "src\Serilog.Sinks.Splunk\Serilog.Sinks.Splunk.csproj", "{1493ABC3-811C-46C7-92ED-CEB7567FB588}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.Sinks.Splunk.FullNetFx", "src\Serilog.Sinks.Splunk.FullNetFx\Serilog.Sinks.Splunk.FullNetFx.csproj", "{17DEED0F-F9CB-48FB-B4DC-53FB6AEE64D7}"
9+
EndProject
10+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{7A774CBB-A6E9-4854-B4DB-4CF860B0C1C5}"
11+
EndProject
12+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "assets", "assets", "{B9B13339-749C-4098-8845-780ED4FA488A}"
13+
ProjectSection(SolutionItems) = preProject
14+
Build.ps1 = Build.ps1
15+
assets\CommonAssemblyInfo.cs = assets\CommonAssemblyInfo.cs
16+
README.md = README.md
17+
assets\Serilog.snk = assets\Serilog.snk
18+
EndProjectSection
19+
EndProject
20+
Global
21+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
22+
Debug|Any CPU = Debug|Any CPU
23+
Release|Any CPU = Release|Any CPU
24+
EndGlobalSection
25+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
26+
{1493ABC3-811C-46C7-92ED-CEB7567FB588}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27+
{1493ABC3-811C-46C7-92ED-CEB7567FB588}.Debug|Any CPU.Build.0 = Debug|Any CPU
28+
{1493ABC3-811C-46C7-92ED-CEB7567FB588}.Release|Any CPU.ActiveCfg = Release|Any CPU
29+
{1493ABC3-811C-46C7-92ED-CEB7567FB588}.Release|Any CPU.Build.0 = Release|Any CPU
30+
{17DEED0F-F9CB-48FB-B4DC-53FB6AEE64D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
31+
{17DEED0F-F9CB-48FB-B4DC-53FB6AEE64D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
32+
{17DEED0F-F9CB-48FB-B4DC-53FB6AEE64D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
33+
{17DEED0F-F9CB-48FB-B4DC-53FB6AEE64D7}.Release|Any CPU.Build.0 = Release|Any CPU
34+
EndGlobalSection
35+
GlobalSection(SolutionProperties) = preSolution
36+
HideSolutionNode = FALSE
37+
EndGlobalSection
38+
GlobalSection(NestedProjects) = preSolution
39+
{1493ABC3-811C-46C7-92ED-CEB7567FB588} = {7A774CBB-A6E9-4854-B4DB-4CF860B0C1C5}
40+
{17DEED0F-F9CB-48FB-B4DC-53FB6AEE64D7} = {7A774CBB-A6E9-4854-B4DB-4CF860B0C1C5}
41+
EndGlobalSection
42+
EndGlobal
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
// Copyright 2014 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.Sinks.Splunk;
20+
using Splunk.Client;
21+
22+
namespace Serilog
23+
{
24+
/// <summary>
25+
/// Adds the WriteTo.SplunkViaHttp() extension method to <see cref="LoggerConfiguration"/>.
26+
/// </summary>
27+
public static class LoggerConfigurationSplunkExtensions
28+
{
29+
/// <summary>
30+
/// Adds a sink that writes log events as to a Splunk instance via http.
31+
/// </summary>
32+
/// <param name="loggerConfiguration">The logger configuration.</param>
33+
/// <param name="context">The Splunk context to log to</param>
34+
/// <param name="batchInterval"></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="batchSizeLimit"></param>
38+
/// <returns>Logger configuration, allowing configuration to continue.</returns>
39+
/// <exception cref="ArgumentNullException">A required parameter is null.</exception>
40+
/// <remarks>TODO: Add link to splunk configuration and wiki</remarks>
41+
public static LoggerConfiguration SplunkViaHttp(
42+
this LoggerSinkConfiguration loggerConfiguration,
43+
SplunkContext context,
44+
int batchSizeLimit,
45+
TimeSpan batchInterval,
46+
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
47+
IFormatProvider formatProvider = null)
48+
{
49+
var sink = new SplunkViaHttpSink(context, batchSizeLimit, batchInterval, formatProvider);
50+
51+
return loggerConfiguration.Sink(sink, restrictedToMinimumLevel);
52+
}
53+
54+
/// <summary>
55+
/// Adds a sink that writes log events as to a Splunk instance via http.
56+
/// </summary>
57+
/// <param name="loggerConfiguration">The logger configuration.</param>
58+
/// <param name="context">The Splunk context to log to</param>
59+
/// <param name="password"></param>
60+
/// <param name="resourceNameSpace"></param>
61+
/// <param name="transmitterArgs"></param>
62+
/// <param name="batchSizeLimit">The size of the batch prior to logging</param>
63+
/// <param name="batchInterval">The interval on which to log via http</param>
64+
/// <param name="restrictedToMinimumLevel">The minimum log event level required in order to write an event to the sink.</param>
65+
/// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
66+
/// <param name="index"></param>
67+
/// <param name="userName"></param>
68+
/// <returns>Logger configuration, allowing configuration to continue.</returns>
69+
/// <exception cref="ArgumentNullException">A required parameter is null.</exception>
70+
/// <remarks>TODO: Add link to splunk configuration and wiki</remarks>
71+
public static LoggerConfiguration SplunkViaHttp(
72+
this LoggerSinkConfiguration loggerConfiguration,
73+
Splunk.Client.Context context,
74+
string index,
75+
string userName,
76+
string password,
77+
int batchSizeLimit,
78+
TimeSpan batchInterval,
79+
Namespace resourceNameSpace,
80+
TransmitterArgs transmitterArgs,
81+
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
82+
IFormatProvider formatProvider = null)
83+
{
84+
var sink = new SplunkViaHttpSink(new SplunkContext(context, index, userName, password, resourceNameSpace, transmitterArgs), batchSizeLimit,batchInterval, formatProvider);
85+
86+
return loggerConfiguration.Sink(sink, restrictedToMinimumLevel);
87+
}
88+
89+
/// <summary>
90+
/// Adds a sink that writes log events as to a Splunk instance via http.
91+
/// </summary>
92+
/// <param name="loggerConfiguration">The logger config</param>
93+
/// <param name="host">The Splunk host that is configured for UDP logging</param>
94+
/// <param name="port">The UDP port</param>
95+
/// <param name="restrictedToMinimumLevel">The minimum log event level required in order to write an event to the sink.</param>
96+
/// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
97+
/// <returns></returns>
98+
/// <remarks>TODO: Add link to splunk configuration and wiki</remarks>
99+
public static LoggerConfiguration SplunkViaUdp(
100+
this LoggerSinkConfiguration loggerConfiguration,
101+
string host,
102+
int port,
103+
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
104+
IFormatProvider formatProvider = null)
105+
{
106+
var sink = new SplunkViaUdpSink(host, port, formatProvider);
107+
108+
return loggerConfiguration.Sink(sink, restrictedToMinimumLevel);
109+
}
110+
111+
112+
/// <summary>
113+
/// Adds a sink that writes log events as to a Splunk instance via UDP.
114+
/// </summary>
115+
/// <param name="loggerConfiguration">The logger config</param>
116+
/// <param name="hostAddresss">The Splunk host that is configured for UDP logging</param>
117+
/// <param name="port">The UDP port</param>
118+
/// <param name="restrictedToMinimumLevel">The minimum log event level required in order to write an event to the sink.</param>
119+
/// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
120+
/// <returns></returns>
121+
/// <remarks>TODO: Add link to splunk configuration and wiki</remarks>
122+
public static LoggerConfiguration SplunkViaUdp(
123+
this LoggerSinkConfiguration loggerConfiguration,
124+
IPAddress hostAddresss,
125+
int port,
126+
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
127+
IFormatProvider formatProvider = null)
128+
{
129+
var sink = new SplunkViaUdpSink(hostAddresss, port, formatProvider);
130+
131+
return loggerConfiguration.Sink(sink, restrictedToMinimumLevel);
132+
}
133+
134+
/// <summary>
135+
/// Adds a sink that writes log events as to a Splunk instance via TCP.
136+
/// </summary>
137+
/// <param name="loggerConfiguration">The logger config</param>
138+
/// <param name="hostAddresss">The Splunk host that is configured for UDP logging</param>
139+
/// <param name="port">The TCP port</param>
140+
/// <param name="restrictedToMinimumLevel">The minimum log event level required in order to write an event to the sink.</param>
141+
/// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
142+
/// <returns></returns>
143+
/// <remarks>TODO: Add link to splunk configuration and wiki</remarks>
144+
public static LoggerConfiguration SplunkViaTcp(
145+
this LoggerSinkConfiguration loggerConfiguration,
146+
IPAddress hostAddresss,
147+
int port,
148+
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
149+
IFormatProvider formatProvider = null)
150+
{
151+
var sink = new SplunkViaTcpSink(hostAddresss, port, formatProvider);
152+
153+
return loggerConfiguration.Sink(sink, restrictedToMinimumLevel);
154+
}
155+
156+
/// <summary>
157+
/// Adds a sink that writes log events as to a Splunk instance via TCP.
158+
/// </summary>
159+
/// <param name="loggerConfiguration">The logger config</param>
160+
/// <param name="host">The Splunk host that is configured for UDP logging</param>
161+
/// <param name="port">The TCP port</param>
162+
/// <param name="restrictedToMinimumLevel">The minimum log event level required in order to write an event to the sink.</param>
163+
/// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
164+
/// <returns></returns>
165+
/// <remarks>TODO: Add link to splunk configuration and wiki</remarks>
166+
public static LoggerConfiguration SplunkViaTcp(
167+
this LoggerSinkConfiguration loggerConfiguration,
168+
string host,
169+
int port,
170+
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
171+
IFormatProvider formatProvider = null)
172+
{
173+
var sink = new SplunkViaTcpSink(host, port, formatProvider);
174+
175+
return loggerConfiguration.Sink(sink, restrictedToMinimumLevel);
176+
}
177+
178+
}
179+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
4+
[assembly: AssemblyTitle("Serilog.Sinks.Splunk.FullNetFx")]
5+
[assembly: AssemblyDescription("Serilog sink for Splunk using .Net 4.5")]
6+
[assembly: AssemblyCopyright("Copyright © Serilog Contributors 2014")]
7+
8+
[assembly: InternalsVisibleTo("Serilog.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100fb8d13fd344a1c" +
9+
"6fe0fe83ef33c1080bf30690765bc6eb0df26ebfdf8f21670c64265b30db09f73a0dea5b3db4c9" +
10+
"d18dbf6d5a25af5ce9016f281014d79dc3b4201ac646c451830fc7e61a2dfd633d34c39f87b818" +
11+
"94191652df5ac63cc40c77f3542f702bda692e6e8a9158353df189007a49da0f3cfd55eb250066" +
12+
"b19485ec")]

0 commit comments

Comments
 (0)