1
0
mirror of https://github.com/square/okhttp.git synced 2025-11-27 18:21:14 +03:00

Add URL to HTTP response logging

Add the URL to the HTTP response when it is logged in the same manner
that the URL is added to the request logging. The added logging adds
some additional clarity when reading logs that contain many
request/response pairs.
This commit is contained in:
Adam Stroud
2015-12-12 01:38:23 -05:00
committed by Jake Wharton
parent 8033d7b73a
commit 062bb14365
2 changed files with 31 additions and 31 deletions

View File

@@ -205,9 +205,9 @@ public final class HttpLoggingInterceptor implements Interceptor {
long tookMs = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startNs);
ResponseBody responseBody = response.body();
logger.log("<-- " + protocol(response.protocol()) + ' ' + response.code() + ' '
+ response.message() + " (" + tookMs + "ms"
+ (!logHeaders ? ", " + responseBody.contentLength() + "-byte body" : "") + ')');
logger.log("<-- " + response.code() + ' ' + response.message() + ' '
+ response.request().urlString() + " (" + tookMs + "ms" + (!logHeaders ? ", "
+ responseBody.contentLength() + "-byte body" : "") + ')');
if (logHeaders) {
Headers headers = response.headers();