Skip to content

Commit 0bd885d

Browse files
committed
Moved levelSwitch to sink options (M.E.C)
Moved parameter levelSwitch in config extension methods for Microsoft.Extensions.Configuration from a method parameter into the MSSqlServerSinkOptions class.
1 parent 6aaf66d commit 0bd885d

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/Serilog.Sinks.MSSqlServer/Configuration/Extensions/Microsoft.Extensions.Configuration/LoggerConfigurationMSSqlServerExtensions.cs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,11 @@ public static LoggerConfiguration MSSqlServer(
9898
/// <param name="sinkOptions">Supplies additional settings for the sink</param>
9999
/// <param name="sinkOptionsSection">A config section defining additional settings for the sink</param>
100100
/// <param name="appConfiguration">Additional application-level configuration. Required if connectionString is a name.</param>
101-
/// <param name="restrictedToMinimumLevel">The minimum level for events passed through the sink. Ignored when <paramref name="levelSwitch"/> is specified.</param>
101+
/// <param name="restrictedToMinimumLevel">The minimum level for events passed through the sink. Ignored when LevelSwitch in <paramref name="sinkOptions"/> is specified.</param>
102102
/// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
103103
/// <param name="columnOptions">An externally-modified group of column settings</param>
104104
/// <param name="columnOptionsSection">A config section defining various column settings</param>
105105
/// <param name="logEventFormatter">Supplies custom formatter for the LogEvent column, or null</param>
106-
/// <param name="levelSwitch">A switch allowing the pass-through minimum level to be changed at runtime.</param>
107106
/// <returns>Logger configuration, allowing configuration to continue.</returns>
108107
/// <exception cref="ArgumentNullException">A required parameter is null.</exception>
109108
public static LoggerConfiguration MSSqlServer(
@@ -116,8 +115,7 @@ public static LoggerConfiguration MSSqlServer(
116115
IFormatProvider formatProvider = null,
117116
ColumnOptions columnOptions = null,
118117
IConfigurationSection columnOptionsSection = null,
119-
ITextFormatter logEventFormatter = null,
120-
LoggingLevelSwitch levelSwitch = null)
118+
ITextFormatter logEventFormatter = null)
121119
{
122120
if (loggerConfiguration == null)
123121
throw new ArgumentNullException(nameof(loggerConfiguration));
@@ -131,7 +129,7 @@ public static LoggerConfiguration MSSqlServer(
131129
IPeriodicBatchingSinkFactory periodicBatchingSinkFactory = new PeriodicBatchingSinkFactory();
132130
var periodicBatchingSink = periodicBatchingSinkFactory.Create(sink, sinkOptions);
133131

134-
return loggerConfiguration.Sink(periodicBatchingSink, restrictedToMinimumLevel, levelSwitch);
132+
return loggerConfiguration.Sink(periodicBatchingSink, restrictedToMinimumLevel, sinkOptions?.LevelSwitch);
135133
}
136134

137135
/// <summary>
@@ -192,12 +190,11 @@ public static LoggerConfiguration MSSqlServer(
192190
/// <param name="sinkOptions">Supplies additional settings for the sink</param>
193191
/// <param name="sinkOptionsSection">A config section defining additional settings for the sink</param>
194192
/// <param name="appConfiguration">Additional application-level configuration. Required if connectionString is a name.</param>
195-
/// <param name="restrictedToMinimumLevel">The minimum level for events passed through the sink. Ignored when <paramref name="levelSwitch"/> is specified.</param>
193+
/// <param name="restrictedToMinimumLevel">The minimum level for events passed through the sink. Ignored when LevelSwitch in <paramref name="sinkOptions"/> is specified.</param>
196194
/// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
197195
/// <param name="columnOptions">An externally-modified group of column settings</param>
198196
/// <param name="columnOptionsSection">A config section defining various column settings</param>
199197
/// <param name="logEventFormatter">Supplies custom formatter for the LogEvent column, or null</param>
200-
/// <param name="levelSwitch">A switch allowing the pass-through minimum level to be changed at runtime.</param>
201198
/// <returns>Logger configuration, allowing configuration to continue.</returns>
202199
/// <exception cref="ArgumentNullException">A required parameter is null.</exception>
203200
public static LoggerConfiguration MSSqlServer(
@@ -210,8 +207,7 @@ public static LoggerConfiguration MSSqlServer(
210207
IFormatProvider formatProvider = null,
211208
ColumnOptions columnOptions = null,
212209
IConfigurationSection columnOptionsSection = null,
213-
ITextFormatter logEventFormatter = null,
214-
LoggingLevelSwitch levelSwitch = null)
210+
ITextFormatter logEventFormatter = null)
215211
{
216212
if (loggerAuditSinkConfiguration == null)
217213
throw new ArgumentNullException(nameof(loggerAuditSinkConfiguration));
@@ -222,7 +218,7 @@ public static LoggerConfiguration MSSqlServer(
222218
IMSSqlServerAuditSinkFactory auditSinkFactory = new MSSqlServerAuditSinkFactory();
223219
var auditSink = auditSinkFactory.Create(connectionString, sinkOptions, formatProvider, columnOptions, logEventFormatter);
224220

225-
return loggerAuditSinkConfiguration.Sink(auditSink, restrictedToMinimumLevel, levelSwitch);
221+
return loggerAuditSinkConfiguration.Sink(auditSink, restrictedToMinimumLevel, sinkOptions?.LevelSwitch);
226222
}
227223

228224
private static void ReadConfiguration(

0 commit comments

Comments
 (0)