Skip to content

Commit 46d3076

Browse files
committed
Reformatting/cleanup
1 parent 3312716 commit 46d3076

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/Serilog.Sinks.Async/LoggerConfigurationAsyncExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public static class LoggerConfigurationAsyncExtensions
1616
/// <param name="loggerSinkConfiguration">The <see cref="LoggerSinkConfiguration"/> being configured.</param>
1717
/// <param name="configure">An action that configures the wrapped sink.</param>
1818
/// <param name="bufferSize">The size of the concurrent queue used to feed the background worker thread. If
19-
/// the thread is unable to process events quickly enough and the queue is filled, subsequent events will be
19+
/// the thread is unable to process events quickly enough and the queue is filled, subsequent events will be
2020
/// dropped until room is made in the queue.</param>
2121
/// <returns>A <see cref="LoggerConfiguration"/> allowing configuration to continue.</returns>
2222
[EditorBrowsable(EditorBrowsableState.Never)]
@@ -34,8 +34,8 @@ public static LoggerConfiguration Async(
3434
/// <param name="loggerSinkConfiguration">The <see cref="LoggerSinkConfiguration"/> being configured.</param>
3535
/// <param name="configure">An action that configures the wrapped sink.</param>
3636
/// <param name="bufferSize">The size of the concurrent queue used to feed the background worker thread. If
37-
/// the thread is unable to process events quickly enough and the queue is filled, depending on
38-
/// <paramref name="blockWhenFull"/> the queue will block or subsequent events will be dropped until
37+
/// the thread is unable to process events quickly enough and the queue is filled, depending on
38+
/// <paramref name="blockWhenFull"/> the queue will block or subsequent events will be dropped until
3939
/// room is made in the queue.</param>
4040
/// <param name="blockWhenFull">Block when the queue is full, instead of dropping events.</param>
4141
/// <returns>A <see cref="LoggerConfiguration"/> allowing configuration to continue.</returns>

src/Serilog.Sinks.Async/Sinks/Async/BackgroundWorkerSink.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
using System;
22
using System.Collections.Concurrent;
33
using System.Threading;
4+
using System.Threading.Tasks;
45
using Serilog.Core;
56
using Serilog.Debugging;
67
using Serilog.Events;
7-
using System.Threading.Tasks;
88

99
namespace Serilog.Sinks.Async
1010
{
1111
sealed class BackgroundWorkerSink : ILogEventSink, IDisposable
1212
{
1313
readonly ILogEventSink _pipeline;
14-
readonly int _bufferCapacity;
1514
readonly bool _blockWhenFull;
1615
readonly BlockingCollection<LogEvent> _queue;
1716
readonly Task _worker;
@@ -21,15 +20,14 @@ public BackgroundWorkerSink(ILogEventSink pipeline, int bufferCapacity, bool blo
2120
if (pipeline == null) throw new ArgumentNullException(nameof(pipeline));
2221
if (bufferCapacity <= 0) throw new ArgumentOutOfRangeException(nameof(bufferCapacity));
2322
_pipeline = pipeline;
24-
_bufferCapacity = bufferCapacity;
2523
_blockWhenFull = blockWhenFull;
26-
_queue = new BlockingCollection<LogEvent>(_bufferCapacity);
24+
_queue = new BlockingCollection<LogEvent>(bufferCapacity);
2725
_worker = Task.Factory.StartNew(Pump, CancellationToken.None, TaskCreationOptions.LongRunning | TaskCreationOptions.DenyChildAttach, TaskScheduler.Default);
2826
}
2927

3028
public void Emit(LogEvent logEvent)
3129
{
32-
if (this._queue.IsAddingCompleted)
30+
if (_queue.IsAddingCompleted)
3331
return;
3432

3533
try
@@ -41,12 +39,12 @@ public void Emit(LogEvent logEvent)
4139
else
4240
{
4341
if (!_queue.TryAdd(logEvent))
44-
SelfLog.WriteLine("{0} unable to enqueue, capacity {1}", typeof(BackgroundWorkerSink), _bufferCapacity);
42+
SelfLog.WriteLine("{0} unable to enqueue, capacity {1}", typeof(BackgroundWorkerSink), _queue.BoundedCapacity);
4543
}
4644
}
4745
catch (InvalidOperationException)
4846
{
49-
// Thrown in the event of a race condition when we try to add another event after
47+
// Thrown in the event of a race condition when we try to add another event after
5048
// CompleteAdding has been called
5149
}
5250
}

0 commit comments

Comments
 (0)