|
18 | 18 |
|
19 | 19 | using System;
|
20 | 20 | using System.Collections.Generic;
|
21 |
| -using System.Diagnostics; |
22 | 21 | using System.Globalization;
|
23 | 22 | using System.Linq;
|
24 | 23 | using System.Net;
|
25 | 24 | using System.Net.Http;
|
26 | 25 | using System.Net.Http.Headers;
|
27 | 26 | using System.Text;
|
28 |
| -using System.Threading; |
29 | 27 | using System.Threading.Tasks;
|
30 | 28 | using OpenQA.Selenium.Internal;
|
31 | 29 | using OpenQA.Selenium.Internal.Logging;
|
@@ -166,7 +164,10 @@ public virtual Response Execute(Command commandToExecute)
|
166 | 164 | throw new ArgumentNullException(nameof(commandToExecute), "commandToExecute cannot be null");
|
167 | 165 | }
|
168 | 166 |
|
169 |
| - _logger.Debug($"Executing command: {commandToExecute}"); |
| 167 | + if (_logger.IsEnabled(LogEventLevel.Debug)) |
| 168 | + { |
| 169 | + _logger.Debug($"Executing command: {commandToExecute}"); |
| 170 | + } |
170 | 171 |
|
171 | 172 | HttpCommandInfo info = this.commandInfoRepository.GetCommandInfo<HttpCommandInfo>(commandToExecute.Name);
|
172 | 173 | if (info == null)
|
@@ -198,7 +199,10 @@ public virtual Response Execute(Command commandToExecute)
|
198 | 199 |
|
199 | 200 | Response toReturn = this.CreateResponse(responseInfo);
|
200 | 201 |
|
201 |
| - _logger.Debug($"Response: {toReturn}"); |
| 202 | + if (_logger.IsEnabled(LogEventLevel.Debug)) |
| 203 | + { |
| 204 | + _logger.Debug($"Response: {toReturn}"); |
| 205 | + } |
202 | 206 |
|
203 | 207 | return toReturn;
|
204 | 208 | }
|
@@ -279,11 +283,17 @@ private async Task<HttpResponseInfo> MakeHttpRequest(HttpRequestInfo requestInfo
|
279 | 283 | requestMessage.Content.Headers.ContentType = contentTypeHeader;
|
280 | 284 | }
|
281 | 285 |
|
282 |
| - _logger.Trace($">> {requestMessage}"); |
| 286 | + if (_logger.IsEnabled(LogEventLevel.Trace)) |
| 287 | + { |
| 288 | + _logger.Trace($">> {requestMessage}"); |
| 289 | + } |
283 | 290 |
|
284 | 291 | using (HttpResponseMessage responseMessage = await this.client.SendAsync(requestMessage).ConfigureAwait(false))
|
285 | 292 | {
|
286 |
| - _logger.Trace($"<< {responseMessage}"); |
| 293 | + if (_logger.IsEnabled(LogEventLevel.Trace)) |
| 294 | + { |
| 295 | + _logger.Trace($"<< {responseMessage}"); |
| 296 | + } |
287 | 297 |
|
288 | 298 | HttpResponseInfo httpResponseInfo = new HttpResponseInfo();
|
289 | 299 | httpResponseInfo.Body = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false);
|
|
0 commit comments