Commit f9b0977b by YKai

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

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