Skip to content

Commit

Permalink
更改日志打印格式
Browse files Browse the repository at this point in the history
  • Loading branch information
liujingxing committed Nov 15, 2020
1 parent 375d5ae commit 69c4791
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ dependencies {

implementation "com.squareup.okhttp3:okhttp:${okhttp_version}"

// implementation "com.ljx/.rxhttp:rxhttp:${rxhttp_version}"
// implementation "com.ljx.rxhttp:rxhttp:${rxhttp_version}"
// kapt "com.ljx.rxhttp:rxhttp-compiler:${rxhttp_version}"

implementation 'com.ljx.rxlife:rxlife-coroutine:2.0.1'
Expand Down
28 changes: 9 additions & 19 deletions rxhttp/src/main/java/rxhttp/Platform.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,26 +93,16 @@ public void logd(String tag, String message, Throwable e) {

public static void log(int priority, String tag, String content) {
int p = 3072;
int length = content.length();
boolean isBlockPrint = LogUtil.isSegmentPrint();
if (length <= p || !isBlockPrint) {
Log.println(priority, tag, content);
if (length > p) {
String tip = "Because of the logcat log printing limit, " + (length - p) + " bytes are omitted this time. " +
"If you want to print all the logs, call 'RxHttp.setDebug(true, true)' to turn on segment printing";
Log.w(tag, tip);
}
} else {
int i = 0;
while (content.length() > p) {
String logContent = content.substring(0, p);
Log.println(priority, tag, logContent);
Log.println(priority, tag, "<---------------------------------- Segment " + (++i) + " ---------------------------------->");
content = content.substring(p);
}
if (content.length() > 0)
Log.println(priority, tag, content);
int i = 0;
while (content.length() > p) {
String logContent = content.substring(0, p);
Log.println(priority, tag, logContent);
if (!LogUtil.isSegmentPrint()) return;
Log.i(tag, "<---------------------------------- Segment " + (++i) + " ---------------------------------->");
content = content.substring(p);
}
if (content.length() > 0)
Log.println(priority, tag, content);
}
}
}

0 comments on commit 69c4791

Please sign in to comment.