@@ -34,7 +34,7 @@ internal class ObservableDbOperation : DbOperation, IDisposable, IDbBehavior
3434 private readonly ManualResetEventSlim _stopHandle = new ManualResetEventSlim ( true ) ;
3535 private readonly IDbBehavior _dbBehavior ;
3636
37- private string _dependencyQueue = Guid . NewGuid ( ) . ToString ( ) ;
37+ private string ? _dependencyQueue = null ; // Guid.NewGuid().ToString();
3838
3939 private volatile bool _disposing ;
4040 private long _notificationState ;
@@ -130,7 +130,7 @@ public void ExecuteReaderWithUpdates(Action<IDataRecord, DbOperation> processRec
130130
131131 if ( recordCount > 0 )
132132 {
133- _logger . LogTrace ( "{0}{1} records received" , TracePrefix , recordCount ) ;
133+ _logger . LogDebug ( "{0}{1} records received" , TracePrefix , recordCount ) ;
134134
135135 // We got records so start the retry loop again
136136 i = - 1 ;
@@ -154,7 +154,7 @@ public void ExecuteReaderWithUpdates(Action<IDataRecord, DbOperation> processRec
154154 // No records after all retries, set up a SQL notification
155155 try
156156 {
157- _logger . LogTrace ( "{0}Setting up SQL notification" , TracePrefix ) ;
157+ _logger . LogDebug ( "{0}Setting up SQL notification" , TracePrefix ) ;
158158
159159 recordCount = ExecuteReader ( processRecord , command =>
160160 {
@@ -165,7 +165,7 @@ public void ExecuteReaderWithUpdates(Action<IDataRecord, DbOperation> processRec
165165
166166 if ( recordCount > 0 )
167167 {
168- _logger . LogTrace ( "{0}Records were returned by the command that sets up the SQL notification, restarting the receive loop" , TracePrefix ) ;
168+ _logger . LogDebug ( "{0}Records were returned by the command that sets up the SQL notification, restarting the receive loop" , TracePrefix ) ;
169169
170170 i = - 1 ;
171171 break ; // break the inner for loop
@@ -186,7 +186,7 @@ public void ExecuteReaderWithUpdates(Action<IDataRecord, DbOperation> processRec
186186 {
187187 // Failed to change _notificationState from ProcessingUpdates to AwaitingNotification, it was already NotificationReceived
188188
189- _logger . LogTrace ( "{0}The SQL notification fired before the receive loop returned, restarting the receive loop" , TracePrefix ) ;
189+ _logger . LogDebug ( "{0}The SQL notification fired before the receive loop returned, restarting the receive loop" , TracePrefix ) ;
190190
191191 i = - 1 ;
192192 break ; // break the inner for loop
@@ -261,7 +261,7 @@ protected virtual void AddSqlDependency(IDbCommand command, Action<SqlNotificati
261261 SuppressMessage ( "Microsoft.Usage" , "CA1801:ReviewUnusedParameters" , MessageId = "sender" , Justification = "Event handler" ) ]
262262 protected virtual void SqlDependency_OnChange ( SqlNotificationEventArgs e , Action < IDataRecord , DbOperation > processRecord )
263263 {
264- Trace . TraceInformation ( "{0}SQL notification change fired" , TracePrefix ) ;
264+ _logger . LogDebug ( "{0}SQL notification change fired" , TracePrefix ) ;
265265
266266 lock ( _stopLocker )
267267 {
@@ -276,7 +276,7 @@ protected virtual void SqlDependency_OnChange(SqlNotificationEventArgs e, Action
276276
277277 if ( previousState == NotificationState . NotificationReceived )
278278 {
279- Trace . TraceError ( "{0}Overlapping SQL change notifications received, this should never happen, BUG!" , TracePrefix ) ;
279+ _logger . LogError ( "{0}Overlapping SQL change notifications received, this should never happen, BUG!" , TracePrefix ) ;
280280
281281 return ;
282282 }
@@ -367,21 +367,21 @@ protected virtual bool StartSqlDependencyListener()
367367 }
368368 catch ( InvalidOperationException )
369369 {
370- Trace . TraceInformation ( "{0}SQL Service Broker is disabled, disabling query notifications " , TracePrefix ) ;
370+ _logger . LogWarning ( "{0}SQL Service Broker is disabled. Falling back on periodic polling. " , TracePrefix ) ;
371371 _notificationState = NotificationState . Disabled ;
372372 return false ;
373373 }
374374 catch ( NullReferenceException )
375375 {
376376 // Workaround for https://github.com/dotnet/SqlClient/issues/1264
377377
378- Trace . TraceInformation ( "{0}SQL Service Broker is disabled, disabling query notifications " , TracePrefix ) ;
378+ _logger . LogWarning ( "{0}SQL Service Broker is disabled. Falling back on periodic polling. " , TracePrefix ) ;
379379 _notificationState = NotificationState . Disabled ;
380380 return false ;
381381 }
382382 catch ( Exception ex )
383383 {
384- Trace . TraceError ( "{0}Error starting SQL notification listener: {1} " , TracePrefix , ex ) ;
384+ _logger . LogError ( ex , "{0}Error starting SQL notification listener" , TracePrefix ) ;
385385
386386 return false ;
387387 }
@@ -405,7 +405,7 @@ protected virtual void Stop(Exception? ex)
405405 }
406406 catch ( Exception stopEx )
407407 {
408- Trace . TraceError ( "{0}Error occurred while stopping SQL notification listener: {1}" , TracePrefix , stopEx ) ;
408+ _logger . LogError ( stopEx , "{0}Error occurred while stopping SQL notification listener: {1}" , TracePrefix ) ;
409409 }
410410 }
411411
0 commit comments