Skip to content

Commit 540e2d6

Browse files
authored
Merge pull request #6 from SirSeven/master
added the restrictedToMinimumLevel LogEventLevel for the ExceptionLess sink
2 parents 9747493 + 6030e71 commit 540e2d6

File tree

1 file changed

+31
-50
lines changed

1 file changed

+31
-50
lines changed
Lines changed: 31 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,62 @@
11
using System;
22
using Exceptionless;
33
using Serilog.Configuration;
4+
using Serilog.Events;
45
using Serilog.Sinks.Exceptionless;
56

6-
namespace Serilog {
7+
namespace Serilog
8+
{
79
/// <summary>
810
/// The logger configuration exception less extensions.
911
/// </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>
3423
public static LoggerConfiguration Exceptionless(
3524
this LoggerSinkConfiguration loggerConfiguration,
3625
string apiKey,
3726
string serverUrl = null,
3827
Func<EventBuilder, EventBuilder> additionalOperation = null,
39-
bool includeProperties = true
40-
) {
28+
bool includeProperties = true,
29+
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum
30+
)
31+
{
4132
if (loggerConfiguration == null)
4233
throw new ArgumentNullException(nameof(loggerConfiguration));
4334
if (apiKey == null)
4435
throw new ArgumentNullException(nameof(apiKey));
4536

46-
return loggerConfiguration.Sink(new ExceptionlessSink(apiKey, serverUrl, additionalOperation, includeProperties));
37+
return loggerConfiguration.Sink(new ExceptionlessSink(apiKey, serverUrl, additionalOperation, includeProperties), restrictedToMinimumLevel);
4738
}
4839

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>
6948
public static LoggerConfiguration Exceptionless(
7049
this LoggerSinkConfiguration loggerConfiguration,
7150
Func<EventBuilder, EventBuilder> additionalOperation = null,
7251
bool includeProperties = true,
52+
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
7353
ExceptionlessClient client = null
74-
) {
54+
)
55+
{
7556
if (loggerConfiguration == null)
7657
throw new ArgumentNullException(nameof(loggerConfiguration));
7758

78-
return loggerConfiguration.Sink(new ExceptionlessSink(additionalOperation, includeProperties, client));
59+
return loggerConfiguration.Sink(new ExceptionlessSink(additionalOperation, includeProperties, client), restrictedToMinimumLevel);
7960
}
8061
}
8162
}

0 commit comments

Comments
 (0)