Skip to content

Commit 0c1e491

Browse files
committed
Removed bogus null checks
* Removed null checks in config extensions if sink factory returns null before calling Sink() method from Serilog's LoggerSinkConfiguration or LoggerAuditSinkConfiguration. The truth is that our sink factory may not return null. If it does in production, we should let the exception happen. It happened in the tests because of a missing setup on two mocks. * Added missing setups in tests.
1 parent 624287e commit 0c1e491

File tree

2 files changed

+57
-102
lines changed

2 files changed

+57
-102
lines changed

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,6 @@ internal static LoggerConfiguration MSSqlServerInternal(
164164

165165
var periodicBatchingSink = batchingSinkFactory.Create(sink, sinkOptions);
166166

167-
if (periodicBatchingSink == null) return null;
168-
169167
return loggerConfiguration.Sink(periodicBatchingSink, restrictedToMinimumLevel, sinkOptions?.LevelSwitch);
170168
}
171169

@@ -283,8 +281,6 @@ internal static LoggerConfiguration MSSqlServerInternal(
283281

284282
var auditSink = auditSinkFactory.Create(connectionString, sinkOptions, formatProvider, columnOptions, logEventFormatter);
285283

286-
if (auditSink == null) return null;
287-
288284
return loggerAuditSinkConfiguration.Sink(auditSink, restrictedToMinimumLevel, sinkOptions?.LevelSwitch);
289285
}
290286

0 commit comments

Comments
 (0)