@@ -105,7 +105,7 @@ private async Task NotificationLoop(CancellationToken cancellationToken)
105105
106106 try
107107 {
108- _logger . LogDebug ( "{0} Setting up SQL notification" , _tracePrefix ) ;
108+ _logger . LogDebug ( "{HubStream}: Setting up SQL notification" , _tracePrefix ) ;
109109
110110 var tcs = new TaskCompletionSource < SqlNotificationEventArgs > ( ) ;
111111 var cancelReg = cancellationToken . Register ( ( t ) => ( ( TaskCompletionSource < SqlNotificationEventArgs > ) t ! ) . TrySetCanceled ( ) , tcs ) ;
@@ -124,11 +124,11 @@ private async Task NotificationLoop(CancellationToken cancellationToken)
124124 recordCount = await ReadRows ( null ) ;
125125 }
126126
127- _logger . LogDebug ( "{0} Records were returned by the command that sets up the SQL notification, restarting the receive loop" , _tracePrefix ) ;
127+ _logger . LogDebug ( "{HubStream}: Records were returned by the command that sets up the SQL notification, restarting the receive loop" , _tracePrefix ) ;
128128 continue ;
129129 }
130130
131- _logger . LogTrace ( "{0} No records received while setting up SQL notification" , _tracePrefix ) ;
131+ _logger . LogTrace ( "{HubStream}: No records received while setting up SQL notification" , _tracePrefix ) ;
132132
133133 var depResult = await tcs . Task ;
134134 cancelReg . Dispose ( ) ;
@@ -140,7 +140,7 @@ private async Task NotificationLoop(CancellationToken cancellationToken)
140140 case SqlNotificationType . Change when depResult . Info is SqlNotificationInfo . Update :
141141 // Typically means new records are available. (TODO: verify this?).
142142 // Loop again to pick them up by performing another query.
143- _logger . LogTrace ( "{0} SQL notification details: Type={1}, Source={2}, Info={3}" , _tracePrefix , depResult . Type , depResult . Source , depResult . Info ) ;
143+ _logger . LogTrace ( "{HubStream}: SQL notification details: Type={1}, Source={2}, Info={3}" , _tracePrefix , depResult . Type , depResult . Source , depResult . Info ) ;
144144
145145 // Read rows immediately, since on the next loop we know for certain there will be rows.
146146 // There's no point doing a full loop that includes setting up a SqlDependency that
@@ -153,14 +153,14 @@ private async Task NotificationLoop(CancellationToken cancellationToken)
153153
154154 case SqlNotificationType . Change when depResult . Source is SqlNotificationSource . Timeout :
155155 // Expected while there is no activity. We put a timeout on our SqlDependency so they're not running infinitely.
156- _logger . LogTrace ( "{0} SQL notification timed out (this is expected every {1} seconds)" , _tracePrefix , _dependencyTimeout . TotalSeconds ) ;
156+ _logger . LogTrace ( "{HubStream}: SQL notification timed out (this is expected every {1} seconds)" , _tracePrefix , _dependencyTimeout . TotalSeconds ) ;
157157 break ;
158158
159159 case SqlNotificationType . Change :
160160 throw new InvalidOperationException ( $ "Unexpected SQL notification Type={ depResult . Type } , Source={ depResult . Source } , Info={ depResult . Info } ") ;
161161
162162 case SqlNotificationType . Subscribe :
163- _logger . LogError ( "{0} SQL notification subscription error: Type={1}, Source={2}, Info={3}" , _tracePrefix , depResult . Type , depResult . Source , depResult . Info ) ;
163+ _logger . LogError ( "{HubStream}: SQL notification subscription error: Type={1}, Source={2}, Info={3}" , _tracePrefix , depResult . Type , depResult . Source , depResult . Info ) ;
164164
165165 if ( depResult . Info == SqlNotificationInfo . TemplateLimit )
166166 {
@@ -180,14 +180,14 @@ private async Task NotificationLoop(CancellationToken cancellationToken)
180180 catch ( TaskCanceledException ) { return ; }
181181 catch ( Exception ex )
182182 {
183- _logger . LogError ( ex , "{0} Error in SQL notification loop" , _tracePrefix ) ;
183+ _logger . LogError ( ex , "{HubStream}: Error in SQL notification loop" , _tracePrefix ) ;
184184
185185 await Task . Delay ( 1000 , cancellationToken ) ;
186186 continue ;
187187 }
188188 }
189189
190- _logger . LogDebug ( "{0} SQL notification loop fell out" , _tracePrefix ) ;
190+ _logger . LogDebug ( "{HubStream}: SQL notification loop fell out" , _tracePrefix ) ;
191191 await StartLoop ( ) ;
192192 }
193193
@@ -212,7 +212,7 @@ private async Task PollingLoop(CancellationToken cancellationToken)
212212 {
213213 if ( retryDelay > 0 )
214214 {
215- _logger . LogTrace ( "{0} Waiting {1}ms before checking for messages again" , _tracePrefix , retryDelay ) ;
215+ _logger . LogTrace ( "{HubStream}: Waiting {1}ms before checking for messages again" , _tracePrefix , retryDelay ) ;
216216
217217 await Task . Delay ( retryDelay , cancellationToken ) ;
218218 }
@@ -222,20 +222,20 @@ private async Task PollingLoop(CancellationToken cancellationToken)
222222 catch ( TaskCanceledException ) { return ; }
223223 catch ( Exception ex )
224224 {
225- _logger . LogError ( ex , "{0} Error in SQL polling loop" , _tracePrefix ) ;
225+ _logger . LogError ( ex , "{HubStream}: Error in SQL polling loop" , _tracePrefix ) ;
226226 }
227227
228228 if ( recordCount > 0 )
229229 {
230- _logger . LogDebug ( "{0}{1 } records received" , _tracePrefix , recordCount ) ;
230+ _logger . LogDebug ( "{HubStream}: {RecordCount } records received" , _tracePrefix , recordCount ) ;
231231
232232 // We got records so start the retry loop again
233233 // at the lowest delay.
234234 retrySetIndex = - 1 ;
235235 break ;
236236 }
237237
238- _logger . LogTrace ( "{0} No records received" , _tracePrefix ) ;
238+ _logger . LogTrace ( "{HubStream}: No records received" , _tracePrefix ) ;
239239
240240 var isLastRetry = retrySetIndex == delays . Length - 1 && retryIndex == numRetries - 1 ;
241241
@@ -247,7 +247,7 @@ private async Task PollingLoop(CancellationToken cancellationToken)
247247 }
248248 }
249249
250- _logger . LogDebug ( "{0} SQL polling loop fell out" , _tracePrefix ) ;
250+ _logger . LogDebug ( "{HubStream}: SQL polling loop fell out" , _tracePrefix ) ;
251251 await StartLoop ( ) ;
252252 }
253253
@@ -272,7 +272,7 @@ private async Task<long> GetLastPayloadId()
272272 }
273273 catch ( Exception ex )
274274 {
275- _logger . LogError ( ex , "{0} SqlReceiver error starting" , _tracePrefix ) ;
275+ _logger . LogError ( ex , "{HubStream}: SqlReceiver error starting" , _tracePrefix ) ;
276276 throw ;
277277 }
278278 }
@@ -317,22 +317,22 @@ private async Task ProcessRecord(IDataRecord record)
317317 var id = record . GetInt64 ( 0 ) ;
318318 var payload = ( ( SqlDataReader ) record ) . GetSqlBinary ( 1 ) ;
319319
320- _logger . LogTrace ( "{0} SqlReceiver last payload ID={1}, new payload ID={2}" , _tracePrefix , _lastPayloadId , id ) ;
320+ _logger . LogTrace ( "{HubStream}: SqlReceiver last payload ID={1}, new payload ID={2}" , _tracePrefix , _lastPayloadId , id ) ;
321321
322322 if ( id > _lastPayloadId + 1 )
323323 {
324- _logger . LogError ( "{0} Missed message(s) from SQL Server. Expected payload ID {1} but got {2}." , _tracePrefix , _lastPayloadId + 1 , id ) ;
324+ _logger . LogError ( "{HubStream}: Missed message(s) from SQL Server. Expected payload ID {1} but got {2}." , _tracePrefix , _lastPayloadId + 1 , id ) ;
325325 }
326326 else if ( id <= _lastPayloadId )
327327 {
328- _logger . LogInformation ( "{0} Duplicate message(s) or payload ID reset from SQL Server. Last payload ID {1}, this payload ID {2}" , _tracePrefix , _lastPayloadId , id ) ;
328+ _logger . LogInformation ( "{HubStream}: Duplicate message(s) or payload ID reset from SQL Server. Last payload ID {1}, this payload ID {2}" , _tracePrefix , _lastPayloadId , id ) ;
329329 }
330330
331331 _lastPayloadId = id ;
332332
333- _logger . LogTrace ( "{0} Updated receive reader initial payload ID parameter={1}" , _tracePrefix , _lastPayloadId ) ;
333+ _logger . LogTrace ( "{HubStream}: Updated receive reader initial payload ID parameter={1}" , _tracePrefix , _lastPayloadId ) ;
334334
335- _logger . LogTrace ( "{0} Payload {1} received" , _tracePrefix , id ) ;
335+ _logger . LogTrace ( "{HubStream}: Payload {1} received" , _tracePrefix , id ) ;
336336
337337 await _onReceived ! . Invoke ( id , ( byte [ ] ? ) payload ?? Array . Empty < byte > ( ) ) ;
338338 }
@@ -349,30 +349,30 @@ private bool StartSqlDependencyListener()
349349 return false ;
350350 }
351351
352- _logger . LogTrace ( "{0} Starting SQL notification listener" , _tracePrefix ) ;
352+ _logger . LogTrace ( "{HubStream}: Starting SQL notification listener" , _tracePrefix ) ;
353353 try
354354 {
355355 if ( SqlDependency . Start ( _options . ConnectionString ) )
356356 {
357- _logger . LogTrace ( "{0} SQL notification listener started" , _tracePrefix ) ;
357+ _logger . LogTrace ( "{HubStream}: SQL notification listener started" , _tracePrefix ) ;
358358 }
359359 else
360360 {
361- _logger . LogTrace ( "{0} SQL notification listener was already running" , _tracePrefix ) ;
361+ _logger . LogTrace ( "{HubStream}: SQL notification listener was already running" , _tracePrefix ) ;
362362 }
363363 return true ;
364364 }
365365 catch ( InvalidOperationException )
366366 {
367- _logger . LogWarning ( "{0} SQL Service Broker is disabled on the target database." , _tracePrefix ) ;
367+ _logger . LogWarning ( "{HubStream}: SQL Service Broker is disabled on the target database." , _tracePrefix ) ;
368368 _notificationsDisabled = true ;
369369 return false ;
370370 }
371371 catch ( NullReferenceException )
372372 {
373373 // Workaround for https://github.com/dotnet/SqlClient/issues/1264
374374
375- _logger . LogWarning ( "{0} SQL Service Broker is disabled or unsupported by the target database." , _tracePrefix ) ;
375+ _logger . LogWarning ( "{HubStream}: SQL Service Broker is disabled or unsupported by the target database." , _tracePrefix ) ;
376376 _notificationsDisabled = true ;
377377 return false ;
378378 }
@@ -382,13 +382,13 @@ private bool StartSqlDependencyListener()
382382 // Specifically that Azure SQL Database reports that service broker is enabled,
383383 // even though it is entirely unsupported.
384384
385- _logger . LogWarning ( "{0} SQL Service Broker is unsupported by the target database." , _tracePrefix ) ;
385+ _logger . LogWarning ( "{HubStream}: SQL Service Broker is unsupported by the target database." , _tracePrefix ) ;
386386 _notificationsDisabled = true ;
387387 return false ;
388388 }
389389 catch ( Exception ex )
390390 {
391- _logger . LogError ( ex , "{0} Error starting SQL notification listener" , _tracePrefix ) ;
391+ _logger . LogError ( ex , "{HubStream}: Error starting SQL notification listener" , _tracePrefix ) ;
392392
393393 return false ;
394394 }
0 commit comments