Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

Commit

Permalink
Merge branch 'feature/7.x-support' of github.com:Mpdreamz/serilog-sin…
Browse files Browse the repository at this point in the history
…ks-elasticsearch into feature/7.x-support
  • Loading branch information
Mpdreamz committed Jul 12, 2019
2 parents b516297 + 154678a commit c35e764
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 7 deletions.
11 changes: 11 additions & 0 deletions Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ echo "In directory: $PSScriptRoot"

$solution = "serilog-sinks-elasticsearch.sln"
$test = "test\\Serilog.Sinks.Elasticsearch.Tests\\Serilog.Sinks.Elasticsearch.Tests.csproj"
$testIntegration = "test\\Serilog.Sinks.Elasticsearch.IntegrationTests\\Serilog.Sinks.Elasticsearch.IntegrationTests.csproj"
[string[]]$projects = @(
("src\\Serilog.Sinks.Elasticsearch\\Serilog.Sinks.Elasticsearch.csproj"),
("src\\Serilog.Formatting.Elasticsearch\\Serilog.Formatting.Elasticsearch.csproj")
Expand All @@ -22,6 +23,16 @@ function Invoke-Build()
Write-Output "The tests failed"
exit 1
}

Write-Output "Running integration tests"
# Tee-Object forces console redirection on vstest which magically makes Console.WriteLine works again.
# This allows you to see the console out of Elastic.Xunit while its running
& dotnet test $testIntegration -c Release | Tee-Object -Variable integ
if($LASTEXITCODE -ne 0)
{
Write-Output "The integration tests failed"
exit 1
}

Write-Output "Creating packages"
foreach ($project in $projects)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<tags>serilog logging elasticsearch formatters</tags>
<dependencies>
<dependency id="Serilog" version="2.8.0" />
<dependency id="System.Diagnostics.DiagnosticSource" version="[4.5.1,)" />
</dependencies>
</metadata>
<files>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<PackageReference Include="Serilog.Sinks.File" Version="4.0.0" />
<PackageReference Include="Serilog.Sinks.PeriodicBatching" Version="2.1.1" />
<PackageReference Include="Elasticsearch.Net" Version="7.0.0" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.5.1" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Serilog.Sinks.Elasticsearch.Tests.Domain;
using Nest.JsonNetSerializer;
using System.Collections;
using System.Threading;

namespace Serilog.Sinks.Elasticsearch.Tests
{
Expand Down Expand Up @@ -135,7 +136,7 @@ Func<int> templateExistReturnCode

public override TReturn Request<TReturn>(RequestData requestData)
{
MemoryStream ms = new MemoryStream();
var ms = new MemoryStream();
if (requestData.PostData != null)
requestData.PostData.Write(ms, new ConnectionConfiguration());

Expand All @@ -155,6 +156,29 @@ public override TReturn Request<TReturn>(RequestData requestData)
var responseStream = new MemoryStream();
return ResponseBuilder.ToResponse<TReturn>(requestData, null, this._templateExistReturnCode(), Enumerable.Empty<string>(), responseStream);
}

public override async Task<TResponse> RequestAsync<TResponse>(RequestData requestData, CancellationToken cancellationToken)
{
var ms = new MemoryStream();
if (requestData.PostData != null)
await requestData.PostData.WriteAsync(ms, new ConnectionConfiguration(), cancellationToken);

switch (requestData.Method)
{
case HttpMethod.PUT:
_seenHttpPuts.Add(Tuple.Create(requestData.Uri, Encoding.UTF8.GetString(ms.ToArray())));
break;
case HttpMethod.POST:
_seenHttpPosts.Add(Encoding.UTF8.GetString(ms.ToArray()));
break;
case HttpMethod.HEAD:
_seenHttpHeads.Add(this._templateExistReturnCode());
break;
}

var responseStream = new MemoryStream();
return await ResponseBuilder.ToResponseAsync<TResponse>(requestData, null, this._templateExistReturnCode(), Enumerable.Empty<string>(), responseStream, null, cancellationToken);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks>
<TargetFrameworks>netcoreapp2.1;net461</TargetFrameworks>
<AssemblyName>Serilog.Sinks.Elasticsearch.Tests</AssemblyName>
<PackageId>Serilog.Sinks.Elasticsearch.Tests</PackageId>

<DebugSymbols>True</DebugSymbols>
<LangVersion>latest</LangVersion>
<IsTestProject>True</IsTestProject>

<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<PackageTargetFallback Condition=" '$(TargetFramework)' == 'netcoreapp1.1' ">$(PackageTargetFallback);dnxcore50;portable-net45+win8</PackageTargetFallback>
<RuntimeFrameworkVersion Condition=" '$(TargetFramework)' == 'netcoreapp1.1' ">1.1.2</RuntimeFrameworkVersion>
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<GenerateAssemblyInformationalVersionAttribute>false</GenerateAssemblyInformationalVersionAttribute>
Expand Down Expand Up @@ -44,7 +47,6 @@
<DotNetCliToolReference Include="dotnet-version" Version="1.1.2" />

<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
<PackageReference Include="Microsoft.NETCore.Platforms" Version="2.0.1" />
<PackageReference Include="Serilog.Sinks.ColoredConsole" Version="3.0.1" />
<PackageReference Include="dotnet-test-nunit" Version="3.4.0-beta-3" />
<PackageReference Include="xunit" Version="2.3.1" />
Expand Down Expand Up @@ -72,7 +74,7 @@
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
</ItemGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.1' ">
<DefineConstants>$(DefineConstants);DOTNETCORE;PARTIALLY_SERIALIZATION</DefineConstants>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void Should_write_error_to_self_log()
private static ILogger CreateLoggerThatCrashes()
{
var loggerConfig = new LoggerConfiguration()
.WriteTo.Elasticsearch(new ElasticsearchSinkOptions(new Uri("http://localhost:31234"))
.WriteTo.Elasticsearch(new ElasticsearchSinkOptions(new Uri("http://localhost:9199"))
{
AutoRegisterTemplate = true,
TemplateName = "crash"
Expand Down

0 comments on commit c35e764

Please sign in to comment.