|
@@ -25,12 +25,12 @@ public class OkHttpLogInterceptor implements Interceptor {
|
|
//这个chain里面包含了request和response,所以你要什么都可以从这里拿
|
|
//这个chain里面包含了request和response,所以你要什么都可以从这里拿
|
|
Request request = chain.request();
|
|
Request request = chain.request();
|
|
|
|
|
|
- long t1 = System.nanoTime();//请求发起的时间
|
|
|
|
|
|
+ long startTime = System.currentTimeMillis();
|
|
OkHttpLogInterceptor.log.info("----------Start-OkHttp----------------");
|
|
OkHttpLogInterceptor.log.info("----------Start-OkHttp----------------");
|
|
Response response = chain.proceed(request);
|
|
Response response = chain.proceed(request);
|
|
- long t2 = System.nanoTime();//收到响应的时间
|
|
|
|
- OkHttpLogInterceptor.log.info("----------End-OkHttp:" + (t2 - t1) / 1e6d + "毫秒----------");
|
|
|
|
-
|
|
|
|
|
|
+ long endTime = System.currentTimeMillis();
|
|
|
|
+ long duration = endTime - startTime;
|
|
|
|
+ OkHttpLogInterceptor.log.info("----------End-OkHttp:" + duration + "毫秒----------");
|
|
while (!response.isSuccessful() && retryNum < maxRetry) {
|
|
while (!response.isSuccessful() && retryNum < maxRetry) {
|
|
retryNum++;
|
|
retryNum++;
|
|
OkHttpLogInterceptor.log.info("重试次数retryNum=" + retryNum);
|
|
OkHttpLogInterceptor.log.info("重试次数retryNum=" + retryNum);
|