|
@@ -5,6 +5,7 @@ import com.common.LogUtil;
|
|
|
import com.me.network.app.http.HttpClient;
|
|
import com.me.network.app.http.HttpClient;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
|
|
+import java.net.URLDecoder;
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
|
@@ -29,8 +30,8 @@ public class LogInterceptor 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();
|
|
|
- Map<String, Object> headers;
|
|
|
|
|
- Map<String, Object> params;
|
|
|
|
|
|
|
+ Map<String, Object> headers=new HashMap<>();
|
|
|
|
|
+ Map<String, Object> params=new HashMap<>();
|
|
|
Map<String,Object> postParam=new HashMap<>();
|
|
Map<String,Object> postParam=new HashMap<>();
|
|
|
//添加公共Header,公共参数
|
|
//添加公共Header,公共参数
|
|
|
if (builder!=null) {
|
|
if (builder!=null) {
|
|
@@ -78,20 +79,11 @@ public class LogInterceptor implements Interceptor {
|
|
|
Response response = chain.proceed(request);
|
|
Response response = chain.proceed(request);
|
|
|
okhttp3.MediaType mediaType = response.body().contentType();
|
|
okhttp3.MediaType mediaType = response.body().contentType();
|
|
|
String content = response.body().string();
|
|
String content = response.body().string();
|
|
|
-
|
|
|
|
|
if (builder.isDebug()) {
|
|
if (builder.isDebug()) {
|
|
|
- /* Logger.init("PRETTYLOGGER")
|
|
|
|
|
- .hideThreadInfo()
|
|
|
|
|
- .methodCount(0);
|
|
|
|
|
- Logger.i("url:" + JSON.toJSONString(response.request().url().toString()));
|
|
|
|
|
- Logger.i("headers:"+ JSON.toJSONString(response.request().headers().toMultimap()));
|
|
|
|
|
- Logger.i("params:" + JSON.toJSONString(postParam));
|
|
|
|
|
- Logger.init("PRETTYLOGGER")
|
|
|
|
|
- .methodCount(1);*/
|
|
|
|
|
- LogUtil.d("HttpLogs","URL:" + JSON.toJSONString(response.request().url().toString()));
|
|
|
|
|
- LogUtil.d("HttpLogs","HEADER:"+ JSON.toJSONString(response.request().headers().toMultimap()));
|
|
|
|
|
- LogUtil.d("HttpLogs","PARAMS:" + JSON.toJSONString(postParam));
|
|
|
|
|
- LogUtil.d("HttpLogs","TEXT:" + content);
|
|
|
|
|
|
|
+ LogUtil.d("HttpLogs","接口URL:" + JSON.toJSONString(response.request().url().toString()));
|
|
|
|
|
+ LogUtil.d("HttpLogs","请求头:"+ JSON.toJSONString(response.request().headers().toMultimap()));
|
|
|
|
|
+ LogUtil.d("HttpLogs","参数:" + URLDecoder.decode(postParam.toString(),"UTF-8"));
|
|
|
|
|
+ LogUtil.d("HttpLogs","返回结果:" + content);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return response.newBuilder()
|
|
return response.newBuilder()
|