提交 6042eba9 编写于 作者: J jessyan

Move RequestInterceptor to http.log

上级 4bc075bd
......@@ -23,7 +23,7 @@ import android.support.v4.app.FragmentManager;
import com.jess.arms.base.delegate.AppLifecycles;
import com.jess.arms.di.module.GlobalConfigModule;
import com.jess.arms.http.RequestInterceptor;
import com.jess.arms.http.log.RequestInterceptor;
import com.jess.arms.integration.ConfigModule;
import com.jess.arms.utils.ArmsUtils;
import com.squareup.leakcanary.RefWatcher;
......
......@@ -20,7 +20,7 @@ import android.text.TextUtils;
import com.google.gson.reflect.TypeToken;
import com.jess.arms.http.GlobalHttpHandler;
import com.jess.arms.http.RequestInterceptor;
import com.jess.arms.http.log.RequestInterceptor;
import com.jess.arms.utils.ArmsUtils;
import java.util.List;
......
......@@ -21,7 +21,7 @@ import android.support.annotation.Nullable;
import com.google.gson.Gson;
import com.jess.arms.http.GlobalHttpHandler;
import com.jess.arms.http.RequestInterceptor;
import com.jess.arms.http.log.RequestInterceptor;
import com.jess.arms.utils.DataHelper;
import java.io.File;
......
......@@ -23,7 +23,7 @@ import android.text.TextUtils;
import com.bumptech.glide.Glide;
import com.jess.arms.http.BaseUrl;
import com.jess.arms.http.GlobalHttpHandler;
import com.jess.arms.http.RequestInterceptor;
import com.jess.arms.http.log.RequestInterceptor;
import com.jess.arms.http.imageloader.BaseImageLoaderStrategy;
import com.jess.arms.http.imageloader.glide.GlideImageLoaderStrategy;
import com.jess.arms.integration.cache.Cache;
......
......@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.jess.arms.http;
package com.jess.arms.http.log;
import android.text.TextUtils;
......@@ -33,7 +33,7 @@ import timber.log.Timber;
* ================================================
*/
public class FormatPrinter {
public class DefaultFormatPrinter {
private static final String TAG = "ArmsHttpLog";
private static final String LINE_SEPARATOR = System.getProperty("line.separator");
private static final String DOUBLE_SEPARATOR = LINE_SEPARATOR + LINE_SEPARATOR;
......@@ -57,7 +57,7 @@ public class FormatPrinter {
private static final String CENTER_LINE = "├ ";
private static final String DEFAULT_LINE = "│ ";
private FormatPrinter() {
private DefaultFormatPrinter() {
throw new UnsupportedOperationException("you can't instantiate me!");
}
......
......@@ -13,11 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jess.arms.http;
package com.jess.arms.http.log;
import android.support.annotation.Nullable;
import com.jess.arms.di.module.GlobalConfigModule;
import com.jess.arms.http.GlobalHttpHandler;
import com.jess.arms.utils.CharacterHandler;
import com.jess.arms.utils.ZipHelper;
......@@ -82,9 +83,9 @@ public class RequestInterceptor implements Interceptor {
if (logRequest) {
//打印请求信息
if (request.body() != null && isParseable(request.body().contentType())) {
FormatPrinter.printJsonRequest(request, parseParams(request));
DefaultFormatPrinter.printJsonRequest(request, parseParams(request));
} else {
FormatPrinter.printFileRequest(request);
DefaultFormatPrinter.printFileRequest(request);
}
}
......@@ -117,13 +118,13 @@ public class RequestInterceptor implements Interceptor {
final String url = originalResponse.request().url().toString();
if (responseBody != null && isParseable(responseBody.contentType())) {
FormatPrinter.printJsonResponse(TimeUnit.NANOSECONDS.toMillis(t2 - t1),
DefaultFormatPrinter.printJsonResponse(TimeUnit.NANOSECONDS.toMillis(t2 - t1),
isSuccessful, code, header,
isJson(responseBody.contentType()) ?
CharacterHandler.jsonFormat(bodyString) : isXml(responseBody.contentType()) ?
CharacterHandler.xmlFormat(bodyString) : bodyString, segmentList, message, url);
} else {
FormatPrinter.printFileResponse(TimeUnit.NANOSECONDS.toMillis(t2 - t1),
DefaultFormatPrinter.printFileResponse(TimeUnit.NANOSECONDS.toMillis(t2 - t1),
isSuccessful, code, header, segmentList, message, url);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册