@@ -33,7 +33,6 @@ namespace libsignalservice.push
33
33
{
34
34
internal class PushServiceSocket
35
35
{
36
- private static readonly string TAG = "PushServiceSocket" ;
37
36
private static readonly string CREATE_ACCOUNT_SMS_PATH = "/v1/accounts/sms/code/{0}" ;
38
37
private static readonly string CREATE_ACCOUNT_VOICE_PATH = "/v1/accounts/voice/code/{0}" ;
39
38
private static readonly string VERIFY_ACCOUNT_CODE_PATH = "/v1/accounts/code/{0}" ;
@@ -321,7 +320,7 @@ public async Task<SignedPreKeyEntity> GetCurrentSignedPreKey(CancellationToken t
321
320
}
322
321
catch ( /*NotFound*/ Exception e )
323
322
{
324
- Debug . WriteLine ( e . Message , TAG ) ;
323
+ Logger . LogError ( "GetCurrentSignedPreKey() failed: {0} \n {1}" , e . Message , e . StackTrace ) ;
325
324
return null ;
326
325
}
327
326
}
@@ -358,8 +357,6 @@ public async Task<bool> SetCurrentSignedPreKey(CancellationToken token, SignedPr
358
357
{
359
358
throw new Exception ( "Server failed to allocate an attachment key!" ) ;
360
359
}
361
-
362
- Debug . WriteLine ( "Got attachment content location: " + attachmentKey . Location , TAG ) ;
363
360
return ( attachmentKey . Id , attachmentKey . Location ) ;
364
361
}
365
362
@@ -382,9 +379,7 @@ public async Task<string> RetrieveAttachmentDownloadUrl(CancellationToken token,
382
379
}
383
380
384
381
string response = await MakeServiceRequestAsync ( token , path , "GET" , null ) ;
385
- Debug . WriteLine ( "PushServiceSocket: Received resp " + response ) ;
386
382
AttachmentDescriptor descriptor = JsonUtil . FromJson < AttachmentDescriptor > ( response ) ;
387
- Debug . WriteLine ( "PushServiceSocket: Attachment: " + attachmentId + " is at: " + descriptor . Location ) ;
388
383
return descriptor . Location ;
389
384
}
390
385
@@ -498,10 +493,9 @@ private async Task DownloadAttachment(CancellationToken token, string url, Strea
498
493
{
499
494
HttpClient connection = Util . CreateHttpClient ( ) ;
500
495
var headers = connection . DefaultRequestHeaders ;
501
- Debug . WriteLine ( "downloading " + url ) ;
502
496
HttpRequestMessage req = new HttpRequestMessage ( HttpMethod . Get , url ) ;
503
497
req . Content = new StringContent ( "" ) ;
504
- req . Content . Headers . ContentType = new System . Net . Http . Headers . MediaTypeHeaderValue ( "application/octet-stream" ) ;
498
+ req . Content . Headers . ContentType = new MediaTypeHeaderValue ( "application/octet-stream" ) ;
505
499
using ( var resp = await connection . SendAsync ( req , token ) )
506
500
{
507
501
Stream input = await resp . Content . ReadAsStreamAsync ( ) ;
@@ -512,7 +506,6 @@ private async Task DownloadAttachment(CancellationToken token, string url, Strea
512
506
read = input . Read ( buffer , 0 , 4096 ) ;
513
507
if ( read == 0 )
514
508
{
515
- Debug . WriteLine ( "PushServiceSocket Downloaded: " + url + " to: " + localDestination ) ;
516
509
localDestination . Flush ( ) ;
517
510
return ;
518
511
}
@@ -522,8 +515,7 @@ private async Task DownloadAttachment(CancellationToken token, string url, Strea
522
515
}
523
516
catch ( Exception ioe )
524
517
{
525
- Debug . WriteLine ( ioe . Message ) ;
526
- Debug . WriteLine ( ioe . StackTrace ) ;
518
+ Logger . LogError ( "DownloadAttachment() failed: {0}\n {1}" , ioe . Message , ioe . StackTrace ) ;
527
519
throw new PushNetworkException ( ioe ) ;
528
520
}
529
521
}
@@ -632,8 +624,7 @@ private async Task<string> MakeServiceRequestAsync(CancellationToken token, stri
632
624
}
633
625
catch ( Exception ioe )
634
626
{
635
- Debug . WriteLine ( ioe . Message ) ;
636
- Debug . WriteLine ( ioe . StackTrace ) ;
627
+ Logger . LogError ( "MakeServiceRequestAsync failed: {0}\n {1}" , ioe . Message , ioe . StackTrace ) ;
637
628
throw new PushNetworkException ( ioe ) ;
638
629
}
639
630
@@ -654,8 +645,7 @@ private async Task<string> MakeServiceRequestAsync(CancellationToken token, stri
654
645
}
655
646
catch ( Exception e )
656
647
{
657
- Debug . WriteLine ( e ) ;
658
- Debug . WriteLine ( e . StackTrace ) ;
648
+ Logger . LogError ( "MakeServiceRequestAsync() failed: {0}\n {1}" , e . Message , e . StackTrace ) ;
659
649
throw new PushNetworkException ( e ) ;
660
650
}
661
651
throw new MismatchedDevicesException ( mismatchedDevices ) ;
@@ -667,8 +657,7 @@ private async Task<string> MakeServiceRequestAsync(CancellationToken token, stri
667
657
}
668
658
catch ( Exception e )
669
659
{
670
- Debug . WriteLine ( e ) ;
671
- Debug . WriteLine ( e . StackTrace ) ;
660
+ Logger . LogError ( "MakeServiceRequestAsync() failed: {0}\n {1}" , e . Message , e . StackTrace ) ;
672
661
throw new PushNetworkException ( e ) ;
673
662
}
674
663
throw new StaleDevicesException ( staleDevices ) ;
@@ -717,15 +706,13 @@ private async Task<HttpResponseMessage> GetServiceConnectionAsync(CancellationTo
717
706
string url = signalUrl . Url ;
718
707
string hostHeader = signalUrl . HostHeader ;
719
708
Uri uri = new Uri ( string . Format ( "{0}{1}" , url , urlFragment ) ) ;
720
- Debug . WriteLine ( "{0}: Uri {1}" , TAG , uri ) ;
721
709
HttpClient connection = Util . CreateHttpClient ( ) ;
722
710
723
711
var headers = connection . DefaultRequestHeaders ;
724
712
725
713
if ( CredentialsProvider . Password != null )
726
714
{
727
715
string authHeader = GetAuthorizationHeader ( CredentialsProvider ) ;
728
- Debug . WriteLine ( String . Format ( "Authorization: {0}" , authHeader ) , TAG ) ;
729
716
headers . Add ( "Authorization" , authHeader ) ;
730
717
}
731
718
@@ -768,9 +755,7 @@ private async Task<HttpResponseMessage> GetServiceConnectionAsync(CancellationTo
768
755
}
769
756
catch ( Exception e )
770
757
{
771
- Debug . WriteLine ( "getConnection() failed:" , TAG ) ;
772
- Debug . WriteLine ( e . Message ) ;
773
- Debug . WriteLine ( e . StackTrace ) ;
758
+ Logger . LogError ( "GetServiceConnectionAsync() failed: {0}\n {1}" , e . Message , e . StackTrace ) ;
774
759
throw new PushNetworkException ( e ) ;
775
760
}
776
761
}
0 commit comments