12345678910111213141516171819202122232425262728293031323334 |
- package com.emato.ich.api;
- import android.util.Log;
- import java.io.IOException;
- import okhttp3.Interceptor;
- import okhttp3.Request;
- import okhttp3.Response;
- /**
- * okhttp请求响应日志拦截器
- * 已废弃
- */
- public class LoggingInterceptor implements Interceptor {
- public static final String TAG = "Http_log";
- @Override
- public Response intercept(Interceptor.Chain chain) throws IOException {
- Request request = chain.request();
- long t1 = System.nanoTime();
- Log.i(TAG, String.format("Sending request %s on %s%n%s",
- request.url(), chain.connection(), request.headers()));
- Response response = chain.proceed(request);
- long t2 = System.nanoTime();
- Log.i(TAG, String.format("Received response for %s in %.1fms%n%s",
- response.request().url(), (t2 - t1) / 1e6d, response.headers()));
- return response;
- }
- }
|