99using System . Text . RegularExpressions ;
1010using System . Threading ;
1111using System . Threading . Tasks ;
12+ using static StackExchange . Redis . ConnectionMultiplexer ;
1213using static StackExchange . Redis . PhysicalBridge ;
1314
1415namespace StackExchange . Redis
@@ -155,7 +156,7 @@ public void Dispose()
155156 tmp ? . Dispose ( ) ;
156157 }
157158
158- public PhysicalBridge GetBridge ( ConnectionType type , bool create = true , TextWriter log = null )
159+ public PhysicalBridge GetBridge ( ConnectionType type , bool create = true , LogProxy log = null )
159160 {
160161 if ( isDisposed ) return null ;
161162 switch ( type )
@@ -237,7 +238,7 @@ public void SetUnselectable(UnselectableFlags flags)
237238
238239 public ValueTask < WriteResult > TryWriteAsync ( Message message ) => GetBridge ( message . Command ) ? . TryWriteAsync ( message , isSlave ) ?? new ValueTask < WriteResult > ( WriteResult . NoConnectionAvailable ) ;
239240
240- internal void Activate ( ConnectionType type , TextWriter log )
241+ internal void Activate ( ConnectionType type , LogProxy log )
241242 {
242243 GetBridge ( type , true , log ) ;
243244 }
@@ -467,7 +468,7 @@ internal bool IsSelectable(RedisCommand command, bool allowDisconnected = false)
467468 return bridge != null && ( allowDisconnected || bridge . IsConnected ) ;
468469 }
469470
470- internal Task OnEstablishingAsync ( PhysicalConnection connection , TextWriter log )
471+ internal Task OnEstablishingAsync ( PhysicalConnection connection , LogProxy log )
471472 {
472473 try
473474 {
@@ -624,7 +625,7 @@ internal void ReportNextFailure()
624625 subscription ? . ReportNextFailure ( ) ;
625626 }
626627
627- internal Task < bool > SendTracer ( TextWriter log = null )
628+ internal Task < bool > SendTracer ( LogProxy log = null )
628629 {
629630 var msg = GetTracerMessage ( false ) ;
630631 msg = LoggingMessage . Create ( log , msg ) ;
@@ -727,7 +728,7 @@ internal void WriteDirectOrQueueFireAndForgetSync<T>(PhysicalConnection connecti
727728 }
728729 }
729730
730- private PhysicalBridge CreateBridge ( ConnectionType type , TextWriter log )
731+ private PhysicalBridge CreateBridge ( ConnectionType type , LogProxy log )
731732 {
732733 if ( Multiplexer . IsDisposed ) return null ;
733734 Multiplexer . Trace ( type . ToString ( ) ) ;
@@ -736,9 +737,9 @@ private PhysicalBridge CreateBridge(ConnectionType type, TextWriter log)
736737 return bridge ;
737738 }
738739
739- private async Task HandshakeAsync ( PhysicalConnection connection , TextWriter log )
740+ private async Task HandshakeAsync ( PhysicalConnection connection , LogProxy log )
740741 {
741- Multiplexer . LogLocked ( log , "Server handshake" ) ;
742+ log ? . WriteLine ( "Server handshake" ) ;
742743 if ( connection == null )
743744 {
744745 Multiplexer . Trace ( "No connection!?" ) ;
@@ -748,7 +749,7 @@ private async Task HandshakeAsync(PhysicalConnection connection, TextWriter log)
748749 string password = Multiplexer . RawConfig . Password ;
749750 if ( ! string . IsNullOrWhiteSpace ( password ) )
750751 {
751- Multiplexer . LogLocked ( log , "Authenticating (password)" ) ;
752+ log ? . WriteLine ( "Authenticating (password)" ) ;
752753 msg = Message . Create ( - 1 , CommandFlags . FireAndForget , RedisCommand . AUTH , ( RedisValue ) password ) ;
753754 msg . SetInternalCall ( ) ;
754755 await WriteDirectOrQueueFireAndForgetAsync ( connection , msg , ResultProcessor . DemandOK ) . ForAwait ( ) ;
@@ -762,7 +763,7 @@ private async Task HandshakeAsync(PhysicalConnection connection, TextWriter log)
762763 name = nameSanitizer . Replace ( name , "" ) ;
763764 if ( ! string . IsNullOrWhiteSpace ( name ) )
764765 {
765- Multiplexer . LogLocked ( log , "Setting client name: {0}" , name ) ;
766+ log ? . WriteLine ( $ "Setting client name: { name } " ) ;
766767 msg = Message . Create ( - 1 , CommandFlags . FireAndForget , RedisCommand . CLIENT , RedisLiterals . SETNAME , ( RedisValue ) name ) ;
767768 msg . SetInternalCall ( ) ;
768769 await WriteDirectOrQueueFireAndForgetAsync ( connection , msg , ResultProcessor . DemandOK ) . ForAwait ( ) ;
@@ -779,10 +780,10 @@ private async Task HandshakeAsync(PhysicalConnection connection, TextWriter log)
779780
780781 if ( connType == ConnectionType . Interactive )
781782 {
782- Multiplexer . LogLocked ( log , "Auto-configure..." ) ;
783+ log ? . WriteLine ( "Auto-configure..." ) ;
783784 AutoConfigure ( connection ) ;
784785 }
785- Multiplexer . LogLocked ( log , "Sending critical tracer: {0}" , bridge ) ;
786+ log ? . WriteLine ( $ "Sending critical tracer: { bridge } " ) ;
786787 var tracer = GetTracerMessage ( true ) ;
787788 tracer = LoggingMessage . Create ( log , tracer ) ;
788789 await WriteDirectOrQueueFireAndForgetAsync ( connection , tracer , ResultProcessor . EstablishConnection ) . ForAwait ( ) ;
@@ -798,7 +799,7 @@ private async Task HandshakeAsync(PhysicalConnection connection, TextWriter log)
798799 await WriteDirectOrQueueFireAndForgetAsync ( connection , msg , ResultProcessor . TrackSubscriptions ) . ForAwait ( ) ;
799800 }
800801 }
801- Multiplexer . LogLocked ( log , "Flushing outbound buffer" ) ;
802+ log ? . WriteLine ( "Flushing outbound buffer" ) ;
802803 await connection . FlushAsync ( ) . ForAwait ( ) ;
803804 }
804805
0 commit comments