Commit f9b0977b by YKai

feat: 注释掉http请求的日志打印

parent 0d167ce7
...@@ -28,7 +28,7 @@ import okio.BufferedSource; ...@@ -28,7 +28,7 @@ import okio.BufferedSource;
* Des: 解析框架中的网络请求和响应结果并打印 * Des: 解析框架中的网络请求和响应结果并打印
*/ */
public class RequestLogInterceptor implements Interceptor { public class RequestLogInterceptor implements Interceptor {
private DefaultFormatPrinter mPrinter = new DefaultFormatPrinter(); // private DefaultFormatPrinter mPrinter = new DefaultFormatPrinter();
private boolean mIsDebug; private boolean mIsDebug;
private RequestHandler mRequestHandler; private RequestHandler mRequestHandler;
...@@ -40,18 +40,18 @@ public class RequestLogInterceptor implements Interceptor { ...@@ -40,18 +40,18 @@ public class RequestLogInterceptor implements Interceptor {
@Override @Override
public Response intercept(Chain chain) throws IOException { public Response intercept(Chain chain) throws IOException {
Request request = chain.request(); Request request = chain.request();
//
//打印请求信息 // //打印请求信息
if (request.body() != null && isParseable(request.body().contentType())) { // if (request.body() != null && isParseable(request.body().contentType())) {
mPrinter.printJsonRequest(request, parseParams(request)); // mPrinter.printJsonRequest(request, parseParams(request));
} else { // } else {
mPrinter.printFileRequest(request); // mPrinter.printFileRequest(request);
} // }
//
if (mRequestHandler != null) { // if (mRequestHandler != null) {
request = mRequestHandler.onHttpRequestBefore(chain, request); // request = mRequestHandler.onHttpRequestBefore(chain, request);
} // }
long t1 = System.nanoTime(); // long t1 = System.nanoTime();
Response originalResponse; Response originalResponse;
try { try {
originalResponse = chain.proceed(request); originalResponse = chain.proceed(request);
...@@ -59,35 +59,35 @@ public class RequestLogInterceptor implements Interceptor { ...@@ -59,35 +59,35 @@ public class RequestLogInterceptor implements Interceptor {
NetLogUtils.debugInfo("Http Error: " + e); NetLogUtils.debugInfo("Http Error: " + e);
throw e; throw e;
} }
long t2 = System.nanoTime(); // long t2 = System.nanoTime();
ResponseBody responseBody = originalResponse.body(); // ResponseBody responseBody = originalResponse.body();
//打印响应结果 //打印响应结果
String bodyString = null; // String bodyString = null;
if (responseBody != null && isParseable(responseBody.contentType())) { // if (responseBody != null && isParseable(responseBody.contentType())) {
bodyString = printResult(request, originalResponse); // bodyString = printResult(request, originalResponse);
if (mRequestHandler != null) { // if (mRequestHandler != null) {
mRequestHandler.onHttpResultResponse(bodyString, chain, originalResponse); // mRequestHandler.onHttpResultResponse(bodyString, chain, originalResponse);
} // }
} // }
//
if (mIsDebug) { // if (mIsDebug) {
final List<String> segmentList = request.url().encodedPathSegments(); // final List<String> segmentList = request.url().encodedPathSegments();
final String header = originalResponse.headers().toString(); // final String header = originalResponse.headers().toString();
final int code = originalResponse.code(); // final int code = originalResponse.code();
final boolean isSuccessful = originalResponse.isSuccessful(); // final boolean isSuccessful = originalResponse.isSuccessful();
final String message = originalResponse.message(); // final String message = originalResponse.message();
final String url = originalResponse.request().url().toString(); // final String url = originalResponse.request().url().toString();
//
if (responseBody != null && isParseable(responseBody.contentType())) { // if (responseBody != null && isParseable(responseBody.contentType())) {
mPrinter.printJsonResponse(TimeUnit.NANOSECONDS.toMillis(t2 - t1), isSuccessful, // mPrinter.printJsonResponse(TimeUnit.NANOSECONDS.toMillis(t2 - t1), isSuccessful,
code, header, responseBody.contentType(), bodyString, segmentList, message, url); // code, header, responseBody.contentType(), bodyString, segmentList, message, url);
} else { // } else {
mPrinter.printFileResponse(TimeUnit.NANOSECONDS.toMillis(t2 - t1), // mPrinter.printFileResponse(TimeUnit.NANOSECONDS.toMillis(t2 - t1),
isSuccessful, code, header, segmentList, message, url); // isSuccessful, code, header, segmentList, message, url);
} // }
} // }
return originalResponse; return originalResponse;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment