1
1
using System ;
2
- using System . ComponentModel ;
3
2
using Serilog . Configuration ;
4
3
using Serilog . Sinks . Async ;
5
- using Serilog . Events ;
6
4
7
5
namespace Serilog
8
6
{
@@ -11,44 +9,6 @@ namespace Serilog
11
9
/// </summary>
12
10
public static class LoggerConfigurationAsyncExtensions
13
11
{
14
- /// <summary>
15
- /// Configure a sink to be invoked asynchronously, on a background worker thread.
16
- /// </summary>
17
- /// <param name="loggerSinkConfiguration">The <see cref="LoggerSinkConfiguration"/> being configured.</param>
18
- /// <param name="configure">An action that configures the wrapped sink.</param>
19
- /// <param name="bufferSize">The size of the concurrent queue used to feed the background worker thread. If
20
- /// the thread is unable to process events quickly enough and the queue is filled, subsequent events will be
21
- /// dropped until room is made in the queue.</param>
22
- /// <returns>A <see cref="LoggerConfiguration"/> allowing configuration to continue.</returns>
23
- [ EditorBrowsable ( EditorBrowsableState . Never ) ]
24
- public static LoggerConfiguration Async (
25
- this LoggerSinkConfiguration loggerSinkConfiguration ,
26
- Action < LoggerSinkConfiguration > configure ,
27
- int bufferSize )
28
- {
29
- return loggerSinkConfiguration . Async ( configure , bufferSize , false ) ;
30
- }
31
-
32
- /// <summary>
33
- /// Configure a sink to be invoked asynchronously, on a background worker thread.
34
- /// </summary>
35
- /// <param name="loggerSinkConfiguration">The <see cref="LoggerSinkConfiguration"/> being configured.</param>
36
- /// <param name="configure">An action that configures the wrapped sink.</param>
37
- /// <param name="bufferSize">The size of the concurrent queue used to feed the background worker thread. If
38
- /// the thread is unable to process events quickly enough and the queue is filled, depending on
39
- /// <paramref name="blockWhenFull"/> the queue will block or subsequent events will be dropped until
40
- /// room is made in the queue.</param>
41
- /// <param name="blockWhenFull">Block when the queue is full, instead of dropping events.</param>
42
- /// <returns>A <see cref="LoggerConfiguration"/> allowing configuration to continue.</returns>
43
- public static LoggerConfiguration Async (
44
- this LoggerSinkConfiguration loggerSinkConfiguration ,
45
- Action < LoggerSinkConfiguration > configure ,
46
- int bufferSize = 10000 ,
47
- bool blockWhenFull = false )
48
- {
49
- return loggerSinkConfiguration . Async ( configure , null , bufferSize , blockWhenFull ) ;
50
- }
51
-
52
12
/// <summary>
53
13
/// Configure a sink to be invoked asynchronously, on a background worker thread.
54
14
/// Accepts a reference to a <paramref name="monitor"/> that will be supplied the internal state interface for health monitoring purposes.
@@ -65,16 +25,14 @@ public static LoggerConfiguration Async(
65
25
public static LoggerConfiguration Async (
66
26
this LoggerSinkConfiguration loggerSinkConfiguration ,
67
27
Action < LoggerSinkConfiguration > configure ,
68
- IAsyncLogEventSinkMonitor monitor ,
69
28
int bufferSize = 10000 ,
70
- bool blockWhenFull = false )
29
+ bool blockWhenFull = false ,
30
+ IAsyncLogEventSinkMonitor ? monitor = null )
71
31
{
72
- return LoggerSinkConfiguration . Wrap (
73
- loggerSinkConfiguration ,
32
+ var wrapper = LoggerSinkConfiguration . Wrap (
74
33
wrappedSink => new BackgroundWorkerSink ( wrappedSink , bufferSize , blockWhenFull , monitor ) ,
75
- configure ,
76
- LevelAlias . Minimum ,
77
- null ) ;
34
+ configure ) ;
35
+ return loggerSinkConfiguration . Sink ( wrapper ) ;
78
36
}
79
37
}
80
38
}
0 commit comments