1
1
using System ;
2
2
using Exceptionless ;
3
3
using Serilog . Configuration ;
4
+ using Serilog . Events ;
4
5
using Serilog . Sinks . Exceptionless ;
5
6
6
- namespace Serilog {
7
+ namespace Serilog
8
+ {
7
9
/// <summary>
8
10
/// The logger configuration exception less extensions.
9
11
/// </summary>
10
- public static class LoggerSinkConfigurationExtensions {
11
- /// <summary>
12
- /// Creates a new Exceptionless sink with the specified <paramref name="apiKey"/>.
13
- /// </summary>
14
- /// <param name="loggerConfiguration">
15
- /// The logger configuration.
16
- /// </param>
17
- /// <param name="apiKey">
18
- /// The API key that will be used when sending events to the server.
19
- /// </param>
20
- /// <param name="serverUrl">
21
- /// Optional URL of the server events will be sent to.
22
- /// </param>
23
- /// <param name="additionalOperation">
24
- /// Any additional operation to run against the build exceptions
25
- /// </param>
26
- /// <param name="includeProperties">
27
- /// If false it suppressed sending the Serilog properties to Exceptionless
28
- /// </param>
29
- /// <returns>
30
- /// The <see cref="LoggerConfiguration"/>.
31
- /// </returns>
32
- /// <exception cref="ArgumentNullException">
33
- /// </exception>
12
+ public static class LoggerSinkConfigurationExtensions
13
+ {
14
+ /// <summary>Creates a new Exceptionless sink with the specified <paramref name="apiKey"/>.</summary>
15
+ /// <param name="loggerConfiguration">The logger configuration.</param>
16
+ /// <param name="apiKey">The API key that will be used when sending events to the server.</param>
17
+ /// <param name="serverUrl">Optional URL of the server events will be sent to.</param>
18
+ /// <param name="additionalOperation">Any additional operation to run against the build exceptions</param>
19
+ /// <param name="includeProperties">If false it suppressed sending the Serilog properties to Exceptionless</param>
20
+ /// <param name="restrictedToMinimumLevel">The minimum log event level required in order to write an event to the sink.</param>
21
+ /// <returns>The <see cref="LoggerConfiguration"/>.</returns>
22
+ /// <exception cref="ArgumentNullException"></exception>
34
23
public static LoggerConfiguration Exceptionless (
35
24
this LoggerSinkConfiguration loggerConfiguration ,
36
25
string apiKey ,
37
26
string serverUrl = null ,
38
27
Func < EventBuilder , EventBuilder > additionalOperation = null ,
39
- bool includeProperties = true
40
- ) {
28
+ bool includeProperties = true ,
29
+ LogEventLevel restrictedToMinimumLevel = LevelAlias . Minimum
30
+ )
31
+ {
41
32
if ( loggerConfiguration == null )
42
33
throw new ArgumentNullException ( nameof ( loggerConfiguration ) ) ;
43
34
if ( apiKey == null )
44
35
throw new ArgumentNullException ( nameof ( apiKey ) ) ;
45
36
46
- return loggerConfiguration . Sink ( new ExceptionlessSink ( apiKey , serverUrl , additionalOperation , includeProperties ) ) ;
37
+ return loggerConfiguration . Sink ( new ExceptionlessSink ( apiKey , serverUrl , additionalOperation , includeProperties ) , restrictedToMinimumLevel ) ;
47
38
}
48
39
49
- /// <summary>
50
- /// Creates a new Exceptionless sink.
51
- /// </summary>
52
- /// <param name="loggerConfiguration">
53
- /// The logger configuration.
54
- /// </param>
55
- /// <param name="additionalOperation">
56
- /// Any additional operation to run against the build exceptions
57
- /// </param>
58
- /// <param name="includeProperties">
59
- /// If false it suppressed sending the Serilog properties to Exceptionless
60
- /// </param>
61
- /// <param name="client">
62
- /// Optional instance of <see cref="ExceptionlessClient"/> to use.
63
- /// </param>
64
- /// <returns>
65
- /// The <see cref="LoggerConfiguration"/>.
66
- /// </returns>
67
- /// <exception cref="ArgumentNullException">
68
- /// </exception>
40
+ /// <summary>Creates a new Exceptionless sink.</summary>
41
+ /// <param name="loggerConfiguration">The logger configuration.</param>
42
+ /// <param name="additionalOperation">Any additional operation to run against the build exceptions</param>
43
+ /// <param name="includeProperties">If false it suppressed sending the Serilog properties to Exceptionless</param>
44
+ /// <param name="restrictedToMinimumLevel">The minimum log event level required in order to write an event to the sink.</param>
45
+ /// <param name="client">Optional instance of <see cref="ExceptionlessClient"/> to use.</param>
46
+ /// <returns>The <see cref="LoggerConfiguration"/>.</returns>
47
+ /// <exception cref="ArgumentNullException"></exception>
69
48
public static LoggerConfiguration Exceptionless (
70
49
this LoggerSinkConfiguration loggerConfiguration ,
71
50
Func < EventBuilder , EventBuilder > additionalOperation = null ,
72
51
bool includeProperties = true ,
52
+ LogEventLevel restrictedToMinimumLevel = LevelAlias . Minimum ,
73
53
ExceptionlessClient client = null
74
- ) {
54
+ )
55
+ {
75
56
if ( loggerConfiguration == null )
76
57
throw new ArgumentNullException ( nameof ( loggerConfiguration ) ) ;
77
58
78
- return loggerConfiguration . Sink ( new ExceptionlessSink ( additionalOperation , includeProperties , client ) ) ;
59
+ return loggerConfiguration . Sink ( new ExceptionlessSink ( additionalOperation , includeProperties , client ) , restrictedToMinimumLevel ) ;
79
60
}
80
61
}
81
62
}
0 commit comments