Skip to content

Commit

Permalink
Merge pull request #46 from serilog/dev
Browse files Browse the repository at this point in the history
1.4.0 Release
  • Loading branch information
nblumhardt committed Jun 9, 2019
2 parents 0322494 + 8eb1c2b commit 856f8ff
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 46 deletions.
5 changes: 2 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
version: '{build}'
skip_tags: true
image: Visual Studio 2017
configuration: Release
image: Visual Studio 2019
build_script:
- ps: ./Build.ps1
test: off
Expand All @@ -10,7 +9,7 @@ artifacts:
deploy:
- provider: NuGet
api_key:
secure: bd9z4P73oltOXudAjPehwp9iDKsPtC+HbgshOrSgoyQKr5xVK+bxJQngrDJkHdY8
secure: mnSqLheecloK/7XS+OjiDMlttTzhMTRyT2e9AUnS7aHR5AimjOD9vQtfodwagacH
skip_symbols: true
on:
branch: /^(master|dev)$/
Expand Down
2 changes: 2 additions & 0 deletions serilog-sinks-async.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/UserDictionary/Words/=Serilog/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
18 changes: 10 additions & 8 deletions src/Serilog.Sinks.Async/Serilog.Sinks.Async.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

<PropertyGroup>
<Description>Asynchronous sink wrapper for Serilog.</Description>
<AssemblyVersion>1.0.0</AssemblyVersion>
<VersionPrefix>1.3.0</VersionPrefix>
<AssemblyVersion>1.4.0.0</AssemblyVersion>
<VersionPrefix>1.4.0</VersionPrefix>
<Authors>Jezz Santos;Serilog Contributors</Authors>
<TargetFrameworks>net45;netstandard1.1</TargetFrameworks>
<TargetFrameworks>net45;netstandard1.1;net461;netstandard2.0</TargetFrameworks>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>Serilog.Sinks.Async</AssemblyName>
Expand All @@ -15,22 +15,24 @@
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
<PackageId>Serilog.Sinks.Async</PackageId>
<PackageTags>serilog;async</PackageTags>
<PackageIconUrl>http://serilog.net/images/serilog-sink-nuget.png</PackageIconUrl>
<PackageIconUrl>https://serilog.net/images/serilog-sink-nuget.png</PackageIconUrl>
<PackageProjectUrl>https://serilog.net</PackageProjectUrl>
<PackageLicenseUrl>http://www.apache.org/licenses/LICENSE-2.0</PackageLicenseUrl>
<PackageLicense>Apache-2.0</PackageLicense>
<RepositoryUrl>https://github.com/serilog/serilog-sinks-async</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'net45' ">
<PropertyGroup Condition=" '$(TargetFramework)' == 'net45' Or '$(TargetFramework)' == 'net461' ">
<!-- Don't reference the full NETStandard.Library -->
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Serilog" Version="2.7.1" />
<PackageReference Include="Serilog" Version="2.8.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
<ItemGroup Condition=" '$(TargetFramework)' == 'net45' Or '$(TargetFramework)' == 'net461' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
Expand Down
21 changes: 14 additions & 7 deletions src/Serilog.Sinks.Async/Sinks/Async/BackgroundWorkerSink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ namespace Serilog.Sinks.Async
{
sealed class BackgroundWorkerSink : ILogEventSink, IAsyncLogEventSinkInspector, IDisposable
{
readonly ILogEventSink _pipeline;
readonly ILogEventSink _wrappedSink;
readonly bool _blockWhenFull;
readonly BlockingCollection<LogEvent> _queue;
readonly Task _worker;
readonly IAsyncLogEventSinkMonitor _monitor;

long _droppedMessages;

public BackgroundWorkerSink(ILogEventSink pipeline, int bufferCapacity, bool blockWhenFull, IAsyncLogEventSinkMonitor monitor = null)
public BackgroundWorkerSink(ILogEventSink wrappedSink, int bufferCapacity, bool blockWhenFull, IAsyncLogEventSinkMonitor monitor = null)
{
if (bufferCapacity <= 0) throw new ArgumentOutOfRangeException(nameof(bufferCapacity));
_pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline));
_wrappedSink = wrappedSink ?? throw new ArgumentNullException(nameof(wrappedSink));
_blockWhenFull = blockWhenFull;
_queue = new BlockingCollection<LogEvent>(bufferCapacity);
_worker = Task.Factory.StartNew(Pump, CancellationToken.None, TaskCreationOptions.LongRunning | TaskCreationOptions.DenyChildAttach, TaskScheduler.Default);
Expand Down Expand Up @@ -64,7 +64,7 @@ public void Dispose()
// Allow queued events to be flushed
_worker.Wait();

(_pipeline as IDisposable)?.Dispose();
(_wrappedSink as IDisposable)?.Dispose();

_monitor?.StopMonitoring(this);
}
Expand All @@ -75,12 +75,19 @@ void Pump()
{
foreach (var next in _queue.GetConsumingEnumerable())
{
_pipeline.Emit(next);
try
{
_wrappedSink.Emit(next);
}
catch (Exception ex)
{
SelfLog.WriteLine("{0} failed to emit event to wrapped sink: {1}", typeof(BackgroundWorkerSink), ex);
}
}
}
catch (Exception ex)
catch (Exception fatal)
{
SelfLog.WriteLine("{0} fatal error in worker thread: {1}", typeof(BackgroundWorkerSink), ex);
SelfLog.WriteLine("{0} fatal error in worker thread: {1}", typeof(BackgroundWorkerSink), fatal);
}
}

Expand Down
6 changes: 3 additions & 3 deletions test/Serilog.Sinks.Async.PerformanceTests/LatencyBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ namespace Serilog.Sinks.Async.PerformanceTests
{
public class LatencyBenchmark
{
private readonly LogEvent _evt = new LogEvent(DateTimeOffset.Now, LogEventLevel.Information, null,
readonly LogEvent _evt = new LogEvent(DateTimeOffset.Now, LogEventLevel.Information, null,
new MessageTemplate(new[] {new TextToken("Hello")}), new LogEventProperty[0]);

private Logger _syncLogger, _asyncLogger, _fileLogger, _asyncFileLogger;
Logger _syncLogger, _asyncLogger, _fileLogger, _asyncFileLogger;

static LatencyBenchmark()
{
SelfLog.Enable(new TerminatingTextWriter());
}

[Setup]
[GlobalSetup]
public void Reset()
{
foreach (var logger in new[] { _syncLogger, _asyncLogger, _fileLogger, _asyncFileLogger})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net46;netcoreapp1.1</TargetFrameworks>
<TargetFrameworks>net461;netcoreapp2.0</TargetFrameworks>
<AssemblyName>Serilog.Sinks.Async.PerformanceTests</AssemblyName>
<AssemblyOriginatorKeyFile>../../assets/Serilog.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
Expand All @@ -17,10 +17,13 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="BenchmarkDotNet" Version="0.10.6" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.1.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="BenchmarkDotNet" Version="0.11.5" />
<PackageReference Include="Serilog.Sinks.File" Version="3.1.0" />
</ItemGroup>

Expand Down
8 changes: 4 additions & 4 deletions test/Serilog.Sinks.Async.PerformanceTests/SignallingSink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

namespace Serilog.Sinks.Async.PerformanceTests
{
internal class SignallingSink : ILogEventSink
class SignallingSink : ILogEventSink
{
private readonly int _expectedCount;
private readonly ManualResetEvent _wh;
private int _current;
readonly int _expectedCount;
readonly ManualResetEvent _wh;
int _current;

public SignallingSink(int expectedCount)
{
Expand Down
10 changes: 5 additions & 5 deletions test/Serilog.Sinks.Async.PerformanceTests/ThroughputBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ namespace Serilog.Sinks.Async.PerformanceTests
{
public class ThroughputBenchmark
{
private const int Count = 10000;
const int Count = 10000;

private readonly LogEvent _evt = new LogEvent(DateTimeOffset.Now, LogEventLevel.Information, null,
readonly LogEvent _evt = new LogEvent(DateTimeOffset.Now, LogEventLevel.Information, null,
new MessageTemplate(new[] {new TextToken("Hello")}), new LogEventProperty[0]);

private readonly SignallingSink _signal;
private Logger _syncLogger, _asyncLogger;
readonly SignallingSink _signal;
Logger _syncLogger, _asyncLogger;

public ThroughputBenchmark()
{
_signal = new SignallingSink(Count);
}

[Setup]
[GlobalSetup]
public void Reset()
{
_syncLogger?.Dispose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class BackgroundWorkerSinkIntegrationSpec
/// <summary>
/// If <see cref="withDelay" />, then adds a 1sec delay before every fifth element created
/// </summary>
private static void CreateAudits(ILogger logger, int count, bool withDelay)
static void CreateAudits(ILogger logger, int count, bool withDelay)
{
var delay = TimeSpan.FromMilliseconds(1000);
var sw = new Stopwatch();
Expand Down Expand Up @@ -47,7 +47,7 @@ private static void CreateAudits(ILogger logger, int count, bool withDelay)
}
}

private static List<LogEvent> RetrieveEvents(MemorySink sink, int count)
static List<LogEvent> RetrieveEvents(MemorySink sink, int count)
{
Debug.WriteLine("{0:h:mm:ss tt} Retrieving {1} events", DateTime.Now, count);

Expand Down Expand Up @@ -91,9 +91,9 @@ public GivenBufferQueueAndDelays()

public abstract class SinkSpecBase : IDisposable
{
private bool _delayCreation;
private Logger _logger;
private MemorySink _memorySink;
bool _delayCreation;
Logger _logger;
MemorySink _memorySink;

protected SinkSpecBase(bool useBufferedQueue, bool delayCreation)
{
Expand Down
4 changes: 2 additions & 2 deletions test/Serilog.Sinks.Async.Tests/BackgroundWorkerSinkSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,12 @@ public void MonitorParameterAffordsSinkInspectorSuitableForHealthChecking()
Assert.Null(monitor.Inspector);
}

private BackgroundWorkerSink CreateSinkWithDefaultOptions()
BackgroundWorkerSink CreateSinkWithDefaultOptions()
{
return new BackgroundWorkerSink(_logger, 10000, false);
}

private static LogEvent CreateEvent()
static LogEvent CreateEvent()
{
return new LogEvent(DateTimeOffset.MaxValue, LogEventLevel.Error, null,
new MessageTemplate("amessage", Enumerable.Empty<MessageTemplateToken>()),
Expand Down
11 changes: 7 additions & 4 deletions test/Serilog.Sinks.Async.Tests/Serilog.Sinks.Async.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net452;netcoreapp1.0</TargetFrameworks>
<TargetFrameworks>net461;netcoreapp2.0</TargetFrameworks>
<AssemblyName>Serilog.Sinks.Async.Tests</AssemblyName>
<AssemblyOriginatorKeyFile>../../assets/Serilog.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
Expand All @@ -14,9 +14,12 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.1.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit" Version="2.4.1" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 856f8ff

Please sign in to comment.