@@ -247,8 +247,8 @@ export class SignalClient {
247247 private useV0SignalPath = false ;
248248
249249 constructor ( useJSON : boolean = false , loggerOptions : LoggerOptions = { } ) {
250- this . log = getLogger ( loggerOptions . loggerName ?? LoggerNames . Signal ) ;
251250 this . loggerContextCb = loggerOptions . loggerContextCb ;
251+ this . log = getLogger ( loggerOptions . loggerName ?? LoggerNames . Signal , ( ) => this . logContext ) ;
252252 this . useJSON = useJSON ;
253253 this . requestQueue = new AsyncQueue ( ) ;
254254 this . queuedRequests = [ ] ;
@@ -284,10 +284,7 @@ export class SignalClient {
284284 reason ?: ReconnectReason ,
285285 ) : Promise < ReconnectResponse | undefined > {
286286 if ( ! this . options ) {
287- this . log . warn (
288- 'attempted to reconnect without signal options being set, ignoring' ,
289- this . logContext ,
290- ) ;
287+ this . log . warn ( 'attempted to reconnect without signal options being set, ignoring' ) ;
291288 return ;
292289 }
293290 this . state = SignalConnectionState . RECONNECTING ;
@@ -377,10 +374,9 @@ export class SignalClient {
377374 if ( redactedUrl . searchParams . has ( 'access_token' ) ) {
378375 redactedUrl . searchParams . set ( 'access_token' , '<redacted>' ) ;
379376 }
380- this . log . debug ( ` connecting to ${ redactedUrl } `, {
377+ this . log . info ( `signal connecting to ${ redactedUrl } `, {
381378 reconnect : opts . reconnect ,
382379 reconnectReason : opts . reconnectReason ,
383- ...this . logContext ,
384380 } ) ;
385381 if ( this . ws ) {
386382 await this . close ( false ) ;
@@ -399,7 +395,6 @@ export class SignalClient {
399395 }
400396 if ( closeInfo . closeCode !== 1000 ) {
401397 this . log . warn ( `websocket closed` , {
402- ...this . logContext ,
403398 reason : closeInfo . reason ,
404399 code : closeInfo . closeCode ,
405400 wasClean : closeInfo . closeCode === 1000 ,
@@ -466,7 +461,6 @@ export class SignalClient {
466461
467462 if ( this . pingTimeoutDuration && this . pingTimeoutDuration > 0 ) {
468463 this . log . debug ( 'ping config' , {
469- ...this . logContext ,
470464 timeout : this . pingTimeoutDuration ,
471465 interval : this . pingIntervalDuration ,
472466 } ) ;
@@ -555,7 +549,7 @@ export class SignalClient {
555549 await Promise . race ( [ closePromise , sleep ( MAX_WS_CLOSE_TIME ) ] ) ;
556550 }
557551 } catch ( e ) {
558- this . log . debug ( 'websocket error while closing' , { ... this . logContext , error : e } ) ;
552+ this . log . debug ( 'websocket error while closing' , { error : e } ) ;
559553 } finally {
560554 if ( updateState ) {
561555 this . state = SignalConnectionState . DISCONNECTED ;
@@ -566,7 +560,7 @@ export class SignalClient {
566560
567561 // initial offer after joining
568562 sendOffer ( offer : RTCSessionDescriptionInit , offerId : number ) {
569- this . log . debug ( 'sending offer' , { ... this . logContext , offerSdp : offer . sdp } ) ;
563+ this . log . debug ( 'sending offer' , { offerSdp : offer . sdp } ) ;
570564 this . sendRequest ( {
571565 case : 'offer' ,
572566 value : toProtoSessionDescription ( offer , offerId ) ,
@@ -575,15 +569,15 @@ export class SignalClient {
575569
576570 // answer a server-initiated offer
577571 sendAnswer ( answer : RTCSessionDescriptionInit , offerId : number ) {
578- this . log . debug ( 'sending answer' , { ... this . logContext , answerSdp : answer . sdp } ) ;
572+ this . log . debug ( 'sending answer' , { answerSdp : answer . sdp } ) ;
579573 return this . sendRequest ( {
580574 case : 'answer' ,
581575 value : toProtoSessionDescription ( answer , offerId ) ,
582576 } ) ;
583577 }
584578
585579 sendIceCandidate ( candidate : RTCIceCandidateInit , target : SignalTarget ) {
586- this . log . debug ( 'sending ice candidate' , { ... this . logContext , candidate } ) ;
580+ this . log . debug ( 'sending ice candidate' , { candidate } ) ;
587581 return this . sendRequest ( {
588582 case : 'trickle' ,
589583 value : new TrickleRequest ( {
@@ -768,10 +762,7 @@ export class SignalClient {
768762 return ;
769763 }
770764 if ( ! this . streamWriter ) {
771- this . log . error (
772- `cannot send signal request before connected, type: ${ message ?. case } ` ,
773- this . logContext ,
774- ) ;
765+ this . log . error ( `cannot send signal request before connected, type: ${ message ?. case } ` ) ;
775766 return ;
776767 }
777768 const req = new SignalRequest ( { message } ) ;
@@ -783,14 +774,14 @@ export class SignalClient {
783774 await this . streamWriter . write ( req . toBinary ( ) ) ;
784775 }
785776 } catch ( e ) {
786- this . log . error ( 'error sending signal message' , { ... this . logContext , error : e } ) ;
777+ this . log . error ( 'error sending signal message' , { error : e } ) ;
787778 }
788779 }
789780
790781 private handleSignalResponse ( res : SignalResponse ) {
791782 const msg = res . message ;
792783 if ( msg == undefined ) {
793- this . log . debug ( 'received unsupported message' , this . logContext ) ;
784+ this . log . debug ( 'received unsupported message' ) ;
794785 return ;
795786 }
796787
@@ -899,7 +890,7 @@ export class SignalClient {
899890 this . onDataTrackSubscriberHandles ( msg . value ) ;
900891 }
901892 } else {
902- this . log . debug ( 'unsupported message' , { ... this . logContext , msgCase : msg . case } ) ;
893+ this . log . debug ( 'unsupported message' , { msgCase : msg . case } ) ;
903894 }
904895
905896 if ( ! pingHandled ) {
@@ -920,14 +911,14 @@ export class SignalClient {
920911 if ( this . state === SignalConnectionState . DISCONNECTED ) return ;
921912 const onCloseCallback = this . onClose ;
922913 await this . close ( undefined , reason ) ;
923- this . log . debug ( `websocket connection closed: ${ reason } ` , { ... this . logContext , reason } ) ;
914+ this . log . info ( `websocket connection closed: ${ reason } ` , { reason } ) ;
924915 if ( onCloseCallback ) {
925916 onCloseCallback ( reason ) ;
926917 }
927918 }
928919
929920 private handleWSError ( error : unknown ) {
930- this . log . error ( 'websocket error' , { ... this . logContext , error } ) ;
921+ this . log . error ( 'websocket error' , { error } ) ;
931922 }
932923
933924 /**
@@ -937,15 +928,14 @@ export class SignalClient {
937928 private resetPingTimeout ( ) {
938929 this . clearPingTimeout ( ) ;
939930 if ( ! this . pingTimeoutDuration ) {
940- this . log . warn ( 'ping timeout duration not set' , this . logContext ) ;
931+ this . log . warn ( 'ping timeout duration not set' ) ;
941932 return ;
942933 }
943934 this . pingTimeout = CriticalTimers . setTimeout ( ( ) => {
944935 this . log . warn (
945936 `ping timeout triggered. last pong received at: ${ new Date (
946937 Date . now ( ) - this . pingTimeoutDuration ! * 1000 ,
947938 ) . toUTCString ( ) } `,
948- this . logContext ,
949939 ) ;
950940 this . handleOnClose ( 'ping timeout' ) ;
951941 } , this . pingTimeoutDuration * 1000 ) ;
@@ -964,17 +954,17 @@ export class SignalClient {
964954 this . clearPingInterval ( ) ;
965955 this . resetPingTimeout ( ) ;
966956 if ( ! this . pingIntervalDuration ) {
967- this . log . warn ( 'ping interval duration not set' , this . logContext ) ;
957+ this . log . warn ( 'ping interval duration not set' ) ;
968958 return ;
969959 }
970- this . log . debug ( 'start ping interval' , this . logContext ) ;
960+ this . log . debug ( 'start ping interval' ) ;
971961 this . pingInterval = CriticalTimers . setInterval ( ( ) => {
972962 this . sendPing ( ) ;
973963 } , this . pingIntervalDuration * 1000 ) ;
974964 }
975965
976966 private clearPingInterval ( ) {
977- this . log . debug ( 'clearing ping interval' , this . logContext ) ;
967+ this . log . debug ( 'clearing ping interval' ) ;
978968 this . clearPingTimeout ( ) ;
979969 if ( this . pingInterval ) {
980970 CriticalTimers . clearInterval ( this . pingInterval ) ;
@@ -994,6 +984,7 @@ export class SignalClient {
994984 firstMessage ?: SignalResponse ,
995985 ) {
996986 this . state = SignalConnectionState . CONNECTED ;
987+ this . log . info ( 'signal connected' ) ;
997988 clearTimeout ( timeoutHandle ) ;
998989 this . startPingInterval ( ) ;
999990 this . startReadingLoop ( connection . readable . getReader ( ) , firstMessage ) ;
@@ -1031,10 +1022,7 @@ export class SignalClient {
10311022 } ;
10321023 } else {
10331024 // in reconnecting, any message received means signal reconnected and we still need to process it
1034- this . log . debug (
1035- 'declaring signal reconnected without reconnect response received' ,
1036- this . logContext ,
1037- ) ;
1025+ this . log . debug ( 'declaring signal reconnected without reconnect response received' ) ;
10381026 return {
10391027 isValid : true ,
10401028 response : undefined ,
0 commit comments