Skip to content

Commit

Permalink
Merge pull request #41 from serilog/dev
Browse files Browse the repository at this point in the history
Release 2.1.1
  • Loading branch information
merbla authored Oct 25, 2016
2 parents 6ed3774 + 3da9a12 commit cf4f649
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 51 deletions.
10 changes: 10 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
##2.1.1
- [#38](https://github.com/serilog/serilog-sinks-splunk/issues/38)
- Clean up of sample app using examples of host, sourcetype, source override

##2.1.0

* Change to use a standalone formatter
* Resolves #32 & #26 by exposing `HttpMessageHandler`
* Resolves #30 by ignoring OSX build and including tests in `build.sh` for TravisCI

##2.0
- Support for DotNet Core
- Event Collector fluent interface changed to `.WriteTo.EventCollector`
Expand Down
157 changes: 109 additions & 48 deletions sample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,94 +5,155 @@

namespace Sample
{
///
/// Sample 10 false
///
public class Program
{
public static string EventCollectorToken = "1A4D65C9-601A-4717-AD6C-E1EC36A46B69";
public static string EventCollectorToken = "2B94855F-1184-46F7-BFF1-56A3112F627E";

public static void Main(string[] args)
{
var eventsToCreate = 100;
var runSSL = false;

if(args.Length > 0)
eventsToCreate = int.Parse(args[0]);

if(args.Length == 2)
runSSL = bool.Parse(args[1]);

Log.Information("Sample starting up");
Serilog.Debugging.SelfLog.Out = System.Console.Out;
Serilog.Debugging.SelfLog.Enable(System.Console.Out);

// Vanilla Tests just host
UsingHostOnly(eventsToCreate);
UsingFullUri(eventsToCreate);
OverridingSource(eventsToCreate);
OverridingSourceType(eventsToCreate);
OverridingHost(eventsToCreate);
WithNoTemplate(eventsToCreate);

if(runSSL)
UsingSSL(eventsToCreate);

Log.Debug("Done");
}

public static void OverridingSource(int eventsToCreate)
{
// Override Source
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.LiterateConsole()
.WriteTo.EventCollector(
"http://localhost:8088",
Program.EventCollectorToken)
"http://localhost:8088",
Program.EventCollectorToken,
source: "Serilog.Sinks.Splunk.Sample.TestSource")
.Enrich.WithProperty("Serilog.Sinks.Splunk.Sample", "ViaEventCollector")
.Enrich.WithProperty("Serilog.Sinks.Splunk.Sample.TestType", "Vanilla No services/collector")
.CreateLogger();

.Enrich.WithProperty("Serilog.Sinks.Splunk.Sample.TestType", "Source Override")
.CreateLogger();
foreach (var i in Enumerable.Range(0, eventsToCreate))
{
Log.Information("Running vanilla without extended endpoint loop {Counter}", i);
Log.Information("Running source override loop {Counter}", i);
}

Log.CloseAndFlush();

// Vanilla Test with full uri specified
}

public static void OverridingSourceType(int eventsToCreate)
{
// Override Source
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.LiterateConsole()
.WriteTo.EventCollector(
"http://localhost:8088/services/collector",
Program.EventCollectorToken)
"http://localhost:8088",
Program.EventCollectorToken,
sourceType: "Serilog.Sinks.Splunk.Sample.TestSourceType")
.Enrich.WithProperty("Serilog.Sinks.Splunk.Sample", "ViaEventCollector")
.Enrich.WithProperty("Serilog.Sinks.Splunk.Sample.TestType", "Vanilla with full uri specified")
.CreateLogger();

.Enrich.WithProperty("Serilog.Sinks.Splunk.Sample.TestType", "Source Type Override")
.CreateLogger();
foreach (var i in Enumerable.Range(0, eventsToCreate))
{
Log.Information("Running vanilla loop {Counter}", i);
Log.Information("Running source type override loop {Counter}", i);
}

Log.CloseAndFlush();

// Override Source
}

public static void OverridingHost(int eventsToCreate)
{
// Override Host
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.LiterateConsole()
.WriteTo.EventCollector(
"http://localhost:8088",
Program.EventCollectorToken,
source: "Serilog.Sinks.Splunk.Sample")
host: "myamazingmachine")
.Enrich.WithProperty("Serilog.Sinks.Splunk.Sample", "ViaEventCollector")
.Enrich.WithProperty("Serilog.Sinks.Splunk.Sample.TestType", "Source Override")
.Enrich.WithProperty("Serilog.Sinks.Splunk.Sample.TestType", "Host Override")
.CreateLogger();

foreach (var i in Enumerable.Range(0, eventsToCreate))
{
Log.Information("Running source override loop {Counter}", i);
Log.Information("Running host override loop {Counter}", i);
}

Log.CloseAndFlush();

// Override Host

}

public static void UsingFullUri(int eventsToCreate)
{
// Vanilla Test with full uri specified
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.LiterateConsole()
.WriteTo.EventCollector(
"http://localhost:8088",
Program.EventCollectorToken,
host: "myamazingmachine")
"http://localhost:8088/services/collector",
Program.EventCollectorToken)
.Enrich.WithProperty("Serilog.Sinks.Splunk.Sample", "ViaEventCollector")
.Enrich.WithProperty("Serilog.Sinks.Splunk.Sample.TestType", "Host Override")
.Enrich.WithProperty("Serilog.Sinks.Splunk.Sample.TestType", "Vanilla with full uri specified")
.CreateLogger();



foreach (var i in Enumerable.Range(0, eventsToCreate))
{
Log.Information("Running host override loop {Counter}", i);
}
Log.Information("Running vanilla loop with full uri {Counter}", i);
}

Log.CloseAndFlush();
}

public static void UsingHostOnly(int eventsToCreate)
{
// Vanilla Tests just host
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.LiterateConsole()
.WriteTo.EventCollector(
"http://localhost:8088",
Program.EventCollectorToken)
.Enrich.WithProperty("Serilog.Sinks.Splunk.Sample", "ViaEventCollector")
.Enrich.WithProperty("Serilog.Sinks.Splunk.Sample.TestType", "Vanilla No services/collector in uri")
.CreateLogger();

foreach (var i in Enumerable.Range(0, eventsToCreate))
{
Log.Information("Running vanilla without host name and port only {Counter}", i);
}

Log.CloseAndFlush();
}

// No Template
public static void WithNoTemplate(int eventsToCreate)
{
// No Template
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.LiterateConsole()
Expand All @@ -110,26 +171,26 @@ public static void Main(string[] args)
}

Log.CloseAndFlush();
}

// // SSL
// Log.Logger = new LoggerConfiguration()
// .MinimumLevel.Debug()
// .WriteTo.LiterateConsole()
// .WriteTo.EventCollector(
// "https://localhost:8088",
// Program.EventCollectorToken)
// .Enrich.WithProperty("Serilog.Sinks.Splunk.Sample", "ViaEventCollector")
// .Enrich.WithProperty("Serilog.Sinks.Splunk.Sample.TestType", "HTTPS")
// .CreateLogger();
public static void UsingSSL(int eventsToCreate)
{
// SSL
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.LiterateConsole()
.WriteTo.EventCollector(
"https://localhost:8088",
Program.EventCollectorToken)
.Enrich.WithProperty("Serilog.Sinks.Splunk.Sample", "ViaEventCollector")
.Enrich.WithProperty("Serilog.Sinks.Splunk.Sample.TestType", "HTTPS")
.CreateLogger();

// foreach (var i in Enumerable.Range(0, eventsToCreate))
// {
// Log.Information("HTTPS {Counter}", i);
// }
// Log.CloseAndFlush();

Log.Debug("Done");

foreach (var i in Enumerable.Range(0, eventsToCreate))
{
Log.Information("HTTPS {Counter}", i);
}
Log.CloseAndFlush();
}
}
}
2 changes: 1 addition & 1 deletion sample/project.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.0.0",
"version": "2.1.1",
"buildOptions": {
"emitEntryPoint": true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public SplunkJsonFormatter(

if (!string.IsNullOrWhiteSpace(sourceType))
{
suffixWriter.Write(",\"sourceType\":");
suffixWriter.Write(",\"sourcetype\":");
JsonValueFormatter.WriteQuotedJsonString(sourceType, suffixWriter);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Serilog.Sinks.Splunk/project.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.1.0-*",
"version": "2.1.1-*",
"description": "The Splunk Sink for Serilog",
"authors": [
"Matthew Erbs, Serilog Contributors"
Expand Down

0 comments on commit cf4f649

Please sign in to comment.