Skip to content

Commit 6ed3774

Browse files
authored
Merge pull request #35 from serilog/dev
2.1.0 Release
2 parents 021a0b6 + 83e7a94 commit 6ed3774

21 files changed

+437
-174
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ addons:
1818
- zlib1g
1919

2020
os:
21-
- osx
21+
#- osx
2222
- linux
2323

2424
env:
2525
matrix:
2626
- CLI_VERSION=1.0.0-preview2-003121
27-
- CLI_VERSION=Latest
27+
# - CLI_VERSION=Latest
2828

2929
matrix:
3030
allow_failures:

Build.ps1

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,51 @@
1+
echo "build: Build started"
2+
13
Push-Location $PSScriptRoot
24

3-
if(Test-Path .\artifacts) { Remove-Item .\artifacts -Force -Recurse }
5+
if(Test-Path .\artifacts) {
6+
echo "build: Cleaning .\artifacts"
7+
Remove-Item .\artifacts -Force -Recurse
8+
}
49

5-
& dotnet restore
10+
& dotnet restore --no-cache
611

7-
$revision = @{ $true = $env:APPVEYOR_BUILD_NUMBER; $false = 1 }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
12+
$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL];
13+
$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
14+
$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "master" -and $revision -ne "local"]
815

9-
Push-Location src/Serilog.Sinks.Splunk
16+
echo "build: Version suffix is $suffix"
1017

11-
& dotnet pack -c Release -o ..\..\.\artifacts --version-suffix=$revision
12-
if($LASTEXITCODE -ne 0) { exit 1 }
18+
foreach ($src in ls src/*) {
19+
Push-Location $src
1320

21+
echo "build: Packaging project in $src"
22+
23+
& dotnet pack -c Release -o ..\..\artifacts --version-suffix=$suffix
24+
if($LASTEXITCODE -ne 0) { exit 1 }
25+
26+
Pop-Location
27+
}
28+
29+
foreach ($test in ls test/*.PerformanceTests) {
30+
Push-Location $test
31+
32+
echo "build: Building performance test project in $test"
33+
34+
& dotnet build -c Release
35+
if($LASTEXITCODE -ne 0) { exit 2 }
36+
37+
Pop-Location
38+
}
39+
40+
foreach ($test in ls test/*.Tests) {
41+
Push-Location $test
42+
43+
echo "build: Testing project in $test"
44+
45+
& dotnet test -c Release
46+
if($LASTEXITCODE -ne 0) { exit 3 }
47+
48+
Pop-Location
49+
}
1450

15-
Pop-Location
1651
Pop-Location

README.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
# serilog-sinks-splunk
2-
[![Package Logo](http://serilog.net/images/serilog-sink-nuget.png)](http://nuget.org/packages/serilog.sinks.splunk)
1+
# Serilog.Sinks.Splunk
32

43
[![Build status](https://ci.appveyor.com/api/projects/status/yt40wg34t8oj61al?svg=true)](https://ci.appveyor.com/project/serilog/serilog-sinks-splunk)
54
[![NuGet Version](http://img.shields.io/nuget/v/Serilog.Sinks.Splunk.svg?style=flat)](https://www.nuget.org/packages/Serilog.Sinks.Splunk/)
5+
[![Join the chat at https://gitter.im/serilog/serilog](https://img.shields.io/gitter/room/serilog/serilog.svg)](https://gitter.im/serilog/serilog)
6+
7+
A Serilog sink that writes events to the [Splunk](https://splunk.com). Supports .NET 4.5+, .NET Core, and platforms compatible with the [.NET Platform Standard](https://github.com/dotnet/corefx/blob/master/Documentation/architecture/net-platform-standard.md) 1.1 including Windows 8 & UWP, Windows Phone and Xamarin.
68

7-
A sink for Serilog that writes events to [Splunk](https://splunk.com). Moved from the [main Serilog repository](https://github.com/serilog/serilog) for independent versioning. Published to [NuGet](http://www.nuget.org/packages/serilog.sinks.splunk).
9+
[![Package Logo](http://serilog.net/images/serilog-sink-nuget.png)](http://nuget.org/packages/serilog.sinks.splunk)
810

911
**Package** - [Serilog.Sinks.Splunk](http://nuget.org/packages/serilog.sinks.splunk)
10-
| **Platforms** - .NET 4.5+, PCL
1112

1213
## Getting started
1314

@@ -17,12 +18,21 @@ To get started install the *Serilog.Sinks.Splunk* package from Visual Studio's *
1718
PM> Install-Package Serilog.Sinks.Splunk
1819
```
1920

20-
Using the new Event Collector in Splunk 6.3
21+
Using the Event Collector (Splunk 6.3 and above)
2122

2223
```csharp
2324
var log = new LoggerConfiguration()
2425
.WriteTo.EventCollector("https://mysplunk:8088/services/collector", "myeventcollectortoken")
2526
.CreateLogger();
2627
```
2728

28-
More information is available [here](https://github.com/serilog/serilog-sinks-splunk/wiki).
29+
More information is available on the [wiki](https://github.com/serilog/serilog-sinks-splunk/wiki).
30+
31+
### Build status
32+
33+
Branch | AppVeyor | Travis
34+
------------- | ------------- |-------------
35+
master | [![Build status](https://ci.appveyor.com/api/projects/status/yt40wg34t8oj61al/branch/master?svg=true)](https://ci.appveyor.com/project/serilog/serilog-sinks-splunk/branch/dev) | ![](https://travis-ci.org/serilog/serilog-sinks-splunk.svg?branch=master)
36+
dev | [![Build status](https://ci.appveyor.com/api/projects/status/yt40wg34t8oj61al/branch/dev?svg=true)](https://ci.appveyor.com/project/serilog/serilog-sinks-splunk/branch/master) | ![](https://travis-ci.org/serilog/serilog-sinks-splunk.svg?branch=dev)
37+
38+
_Serilog is copyright © 2013-2016 Serilog Contributors - Provided under the [Apache License, Version 2.0](http://apache.org/licenses/LICENSE-2.0.html). Needle and thread logo a derivative of work by [Kenneth Appiah](http://www.kensets.com/)._

appveyor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ deploy:
1919
secure: nvZ/z+pMS91b3kG4DgfES5AcmwwGoBYQxr9kp4XiJHj25SAlgdIxFx++1N0lFH2x
2020
skip_symbols: true
2121
on:
22-
branch: master
22+
branch: /^(master|dev)$/
2323
- provider: GitHub
2424
auth_token:
25-
secure: ggZTqqV1z0xecDoQbeoy3A7xikShCt9FWZIGp95dG9Fo0p5RAT9oGU0ZekHfUIwk
25+
secure: p4LpVhBKxGS5WqucHxFQ5c7C8cP74kbNB0Z8k9Oxx/PMaDQ1+ibmoexNqVU5ZlmX
2626
artifact: /Serilog.*\.nupkg/
2727
tag: v$(appveyor_build_version)
2828
on:

build.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
#!/bin/bash
2+
3+
# Ensure any exit code exits TravisCI
4+
set -e
5+
26
dotnet restore
37
for path in src/*/project.json; do
48
dirname="$(dirname "${path}")"
@@ -8,4 +12,10 @@ done
812
for path in sample/project.json; do
913
dirname="$(dirname "${path}")"
1014
dotnet build ${dirname}
11-
done
15+
done
16+
17+
for path in test/Serilog.Sinks.Splunk.Tests/project.json; do
18+
dirname="$(dirname "${path}")"
19+
dotnet build ${dirname} -f netcoreapp1.0 -c Release
20+
dotnet test ${dirname} -f netcoreapp1.0 -c Release
21+
done

global.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
{
1+
{
22
"projects": [ "src", "test" ],
33
"sdk": {
4-
"version": "1.0.0-preview1-002702"
4+
"version": "1.0.0-preview2-003121"
55
}
66
}

sample/Program.cs

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Sample
77
{
88
public class Program
99
{
10-
public static string EventCollectorToken = "04B42E81-100E-4BED-8AE9-FC5EE4E08602";
10+
public static string EventCollectorToken = "1A4D65C9-601A-4717-AD6C-E1EC36A46B69";
1111

1212
public static void Main(string[] args)
1313
{
@@ -32,10 +32,11 @@ public static void Main(string[] args)
3232

3333
foreach (var i in Enumerable.Range(0, eventsToCreate))
3434
{
35-
Log.Information("Running vanilla without extended endpoint loop {Counter}", i);
36-
Thread.Sleep(5);
35+
Log.Information("Running vanilla without extended endpoint loop {Counter}", i);
3736
}
3837

38+
Log.CloseAndFlush();
39+
3940
// Vanilla Test with full uri specified
4041
Log.Logger = new LoggerConfiguration()
4142
.MinimumLevel.Debug()
@@ -49,10 +50,11 @@ public static void Main(string[] args)
4950

5051
foreach (var i in Enumerable.Range(0, eventsToCreate))
5152
{
52-
Log.Information("Running vanilla loop {Counter}", i);
53-
Thread.Sleep(5);
53+
Log.Information("Running vanilla loop {Counter}", i);
5454
}
5555

56+
Log.CloseAndFlush();
57+
5658
// Override Source
5759
Log.Logger = new LoggerConfiguration()
5860
.MinimumLevel.Debug()
@@ -67,9 +69,10 @@ public static void Main(string[] args)
6769

6870
foreach (var i in Enumerable.Range(0, eventsToCreate))
6971
{
70-
Log.Information("Running source override loop {Counter}", i);
71-
Thread.Sleep(5);
72+
Log.Information("Running source override loop {Counter}", i);
7273
}
74+
75+
Log.CloseAndFlush();
7376

7477
// Override Host
7578
Log.Logger = new LoggerConfiguration()
@@ -85,10 +88,10 @@ public static void Main(string[] args)
8588

8689
foreach (var i in Enumerable.Range(0, eventsToCreate))
8790
{
88-
Log.Information("Running host override loop {Counter}", i);
89-
Thread.Sleep(5);
91+
Log.Information("Running host override loop {Counter}", i);
9092
}
91-
93+
Log.CloseAndFlush();
94+
9295
// No Template
9396
Log.Logger = new LoggerConfiguration()
9497
.MinimumLevel.Debug()
@@ -103,23 +106,28 @@ public static void Main(string[] args)
103106

104107
foreach (var i in Enumerable.Range(0, eventsToCreate))
105108
{
106-
Log.Information("Running no template loop {Counter}", i);
107-
Thread.Sleep(5);
109+
Log.Information("Running no template loop {Counter}", i);
108110
}
109111

110-
// SSL
111-
Log.Logger = new LoggerConfiguration()
112-
.MinimumLevel.Debug()
113-
.WriteTo.LiterateConsole()
114-
.WriteTo.EventCollector(
115-
"https://localhost:8088",
116-
Program.EventCollectorToken)
117-
.Enrich.WithProperty("Serilog.Sinks.Splunk.Sample", "ViaEventCollector")
118-
.Enrich.WithProperty("Serilog.Sinks.Splunk.Sample.TestType", "HTTPS")
119-
.CreateLogger();
112+
Log.CloseAndFlush();
113+
114+
// // SSL
115+
// Log.Logger = new LoggerConfiguration()
116+
// .MinimumLevel.Debug()
117+
// .WriteTo.LiterateConsole()
118+
// .WriteTo.EventCollector(
119+
// "https://localhost:8088",
120+
// Program.EventCollectorToken)
121+
// .Enrich.WithProperty("Serilog.Sinks.Splunk.Sample", "ViaEventCollector")
122+
// .Enrich.WithProperty("Serilog.Sinks.Splunk.Sample.TestType", "HTTPS")
123+
// .CreateLogger();
120124

121-
Log.Debug("Waiting for Events to Flush");
122-
Thread.Sleep(5000);
125+
// foreach (var i in Enumerable.Range(0, eventsToCreate))
126+
// {
127+
// Log.Information("HTTPS {Counter}", i);
128+
// }
129+
// Log.CloseAndFlush();
130+
123131
Log.Debug("Done");
124132

125133
}

serilog-sinks-splunk.sln

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

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 14
4-
VisualStudioVersion = 14.0.24720.0
4+
VisualStudioVersion = 14.0.25420.1
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{7A774CBB-A6E9-4854-B4DB-4CF860B0C1C5}"
77
EndProject
@@ -25,6 +25,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sample", "sample", "{1C75E4
2525
EndProject
2626
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Sample", "src\sample\Sample.xproj", "{17497155-5D94-45DF-81D9-BD960E8CF217}"
2727
EndProject
28+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{B9451AD8-09B9-4C09-A152-FBAE24806614}"
29+
EndProject
30+
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Serilog.Sinks.Splunk.Tests", "test\Serilog.Sinks.Splunk.Tests\Serilog.Sinks.Splunk.Tests.xproj", "{3C2D8E01-5580-426A-BDD9-EC59CD98E618}"
31+
EndProject
2832
Global
2933
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3034
Debug|Any CPU = Debug|Any CPU
@@ -39,12 +43,17 @@ Global
3943
{17497155-5D94-45DF-81D9-BD960E8CF217}.Debug|Any CPU.Build.0 = Debug|Any CPU
4044
{17497155-5D94-45DF-81D9-BD960E8CF217}.Release|Any CPU.ActiveCfg = Release|Any CPU
4145
{17497155-5D94-45DF-81D9-BD960E8CF217}.Release|Any CPU.Build.0 = Release|Any CPU
46+
{3C2D8E01-5580-426A-BDD9-EC59CD98E618}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
47+
{3C2D8E01-5580-426A-BDD9-EC59CD98E618}.Debug|Any CPU.Build.0 = Debug|Any CPU
48+
{3C2D8E01-5580-426A-BDD9-EC59CD98E618}.Release|Any CPU.ActiveCfg = Release|Any CPU
49+
{3C2D8E01-5580-426A-BDD9-EC59CD98E618}.Release|Any CPU.Build.0 = Release|Any CPU
4250
EndGlobalSection
4351
GlobalSection(SolutionProperties) = preSolution
4452
HideSolutionNode = FALSE
4553
EndGlobalSection
4654
GlobalSection(NestedProjects) = preSolution
4755
{32CF915C-3ECD-496C-8FDB-1214581274A6} = {7A774CBB-A6E9-4854-B4DB-4CF860B0C1C5}
4856
{17497155-5D94-45DF-81D9-BD960E8CF217} = {1C75E4A9-4CB1-497C-AD17-B438882051A1}
57+
{3C2D8E01-5580-426A-BDD9-EC59CD98E618} = {B9451AD8-09B9-4C09-A152-FBAE24806614}
4958
EndGlobalSection
5059
EndGlobal

src/Serilog.Sinks.Splunk/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
using System.Runtime.CompilerServices;
33

44
[assembly: AssemblyVersion("2.0.0.0")]
5+
6+
[assembly: InternalsVisibleTo("Serilog.Sinks.Splunk.Tests")]

src/Serilog.Sinks.Splunk/Sinks/Splunk/EventCollectorRequest.cs

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -14,55 +14,11 @@
1414

1515

1616
using System;
17-
using System.Globalization;
1817
using System.Net.Http;
1918
using System.Text;
2019

2120
namespace Serilog.Sinks.Splunk
2221
{
23-
internal class SplunkEvent
24-
{
25-
private string _payload;
26-
27-
internal SplunkEvent(string logEvent, string source, string sourceType, string host, string index, double time)
28-
{
29-
_payload = string.Empty;
30-
31-
var jsonPayLoad = @"{""event"":" + logEvent
32-
.Replace("\r\n", string.Empty);
33-
34-
if (!string.IsNullOrWhiteSpace(source))
35-
{
36-
jsonPayLoad = jsonPayLoad + @",""source"":""" + source + @"""";
37-
}
38-
if (!string.IsNullOrWhiteSpace(sourceType))
39-
{
40-
jsonPayLoad = jsonPayLoad + @",""sourceType"":""" + sourceType + @"""";
41-
}
42-
if (!string.IsNullOrWhiteSpace(host))
43-
{
44-
jsonPayLoad = jsonPayLoad + @",""host"":""" + host + @"""";
45-
}
46-
if (!string.IsNullOrWhiteSpace(index))
47-
{
48-
jsonPayLoad = jsonPayLoad + @",""index"":""" + index + @"""";
49-
}
50-
51-
if (time > 0)
52-
{
53-
jsonPayLoad = jsonPayLoad + @",""time"":" + time.ToString(CultureInfo.InvariantCulture);
54-
}
55-
56-
jsonPayLoad = jsonPayLoad + "}";
57-
_payload = jsonPayLoad;
58-
}
59-
60-
public string Payload
61-
{
62-
get { return _payload; }
63-
}
64-
}
65-
6622
internal class EventCollectorRequest : HttpRequestMessage
6723
{
6824
internal EventCollectorRequest(string splunkHost, string jsonPayLoad, string uri ="services/collector")

0 commit comments

Comments
 (0)