@@ -209,17 +209,17 @@ protected void AssertSelf ()
209209
210210 async Task < HttpResponseMessage > DoProcessRequest ( HttpRequestMessage request , HttpURLConnection httpConnection , CancellationToken cancellationToken )
211211 {
212- if ( true )
213- System . Console . WriteLine ( $ "{ this } .DoProcessRequest ()") ;
212+ if ( Logger . LogNet )
213+ Logger . Log ( LogLevel . Info , LOG_APP , $ "{ this } .DoProcessRequest ()") ;
214214 try {
215- if ( true )
216- System . Console . WriteLine ( $ " connecting") ;
215+ if ( Logger . LogNet )
216+ Logger . Log ( LogLevel . Info , LOG_APP , $ " connecting") ;
217217 await httpConnection . ConnectAsync ( ) . ConfigureAwait ( false ) ;
218- if ( true )
219- System . Console . WriteLine ( $ " connected") ;
218+ if ( Logger . LogNet )
219+ Logger . Log ( LogLevel . Info , LOG_APP , $ " connected") ;
220220 } catch ( Java . Net . ConnectException ex ) {
221- if ( true )
222- System . Console . WriteLine ( $ "Connection exception { ex } ") ;
221+ if ( Logger . LogNet )
222+ Logger . Log ( LogLevel . Info , LOG_APP , $ "Connection exception { ex } ") ;
223223 // Wrap it nicely in a "standard" exception so that it's compatible with HttpClientHandler
224224 throw new WebException ( ex . Message , ex , WebExceptionStatus . ConnectFailure , null ) ;
225225 }
@@ -235,8 +235,8 @@ async Task<HttpResponseMessage> DoProcessRequest (HttpRequestMessage request, Ht
235235 StatusCode = statusCode ,
236236 } ;
237237
238- if ( true )
239- System . Console . WriteLine ( $ "Status code: { statusCode } ") ;
238+ if ( Logger . LogNet )
239+ Logger . Log ( LogLevel . Info , LOG_APP , $ "Status code: { statusCode } ") ;
240240 if ( statusCode == HttpStatusCode . Unauthorized || statusCode == HttpStatusCode . ProxyAuthenticationRequired ) {
241241 // We don't resend the request since that would require new set of credentials if the
242242 // ones provided in Credentials are invalid (or null) and that, in turn, may require asking the
@@ -265,8 +265,8 @@ async Task<HttpResponseMessage> DoProcessRequest (HttpRequestMessage request, Ht
265265 }
266266
267267 if ( ! IsErrorStatusCode ( statusCode ) ) {
268- if ( true )
269- System . Console . WriteLine ( $ "Reading...") ;
268+ if ( Logger . LogNet )
269+ Logger . Log ( LogLevel . Info , LOG_APP , $ "Reading...") ;
270270 Stream inputStream = new BufferedStream ( httpConnection . InputStream ) ;
271271 if ( decompress_here ) {
272272 string [ ] encodings = httpConnection . ContentEncoding ? . Split ( ',' ) ;
@@ -279,8 +279,8 @@ async Task<HttpResponseMessage> DoProcessRequest (HttpRequestMessage request, Ht
279279 }
280280 ret . Content = new StreamContent ( inputStream ) ;
281281 } else {
282- if ( true )
283- System . Console . WriteLine ( $ "Status code is { statusCode } , returning empty content") ;
282+ if ( Logger . LogNet )
283+ Logger . Log ( LogLevel . Info , LOG_APP , $ "Status code is { statusCode } , returning empty content") ;
284284 // For 400 >= response code <= 599 the Java client throws the FileNotFound exeption when attempting to read from the connection
285285 // Client tests require we return no content here
286286 ret . Content = new StringContent ( String . Empty , Encoding . ASCII ) ;
@@ -289,26 +289,26 @@ async Task<HttpResponseMessage> DoProcessRequest (HttpRequestMessage request, Ht
289289
290290 IEnumerable < string > cookieHeaderValue ;
291291 if ( ! UseCookies || CookieContainer == null || ! ret . Headers . TryGetValues ( "Set-Cookie" , out cookieHeaderValue ) || cookieHeaderValue == null ) {
292- if ( true )
293- System . Console . WriteLine ( $ "No cookies") ;
292+ if ( Logger . LogNet )
293+ Logger . Log ( LogLevel . Info , LOG_APP , $ "No cookies") ;
294294 return ret ;
295295 }
296296
297297 try {
298- if ( true )
299- System . Console . WriteLine ( $ "Parsing cookies") ;
298+ if ( Logger . LogNet )
299+ Logger . Log ( LogLevel . Info , LOG_APP , $ "Parsing cookies") ;
300300 CookieContainer . SetCookies ( connectionUri , String . Join ( "," , cookieHeaderValue ) ) ;
301301 } catch ( Exception ex ) {
302302 // We don't want to terminate the response because of a bad cookie, hence just reporting
303303 // the issue. We might consider adding a virtual method to let the user handle the
304304 // issue, but not sure if it's really needed. Set-Cookie header will be part of the
305305 // header collection so the user can always examine it if they spot an error.
306- if ( true )
307- System . Console . WriteLine ( $ "Failed to parse cookies in the server response. { ex . GetType ( ) } : { ex . Message } ") ;
306+ if ( Logger . LogNet )
307+ Logger . Log ( LogLevel . Info , LOG_APP , $ "Failed to parse cookies in the server response. { ex . GetType ( ) } : { ex . Message } ") ;
308308 }
309309
310- if ( true )
311- System . Console . WriteLine ( $ "Returning") ;
310+ if ( Logger . LogNet )
311+ Logger . Log ( LogLevel . Info , LOG_APP , $ "Returning") ;
312312 return ret ;
313313 }
314314
0 commit comments