Commit 1b7c68a9 by 郭倩芳

1.2.8 解决日志内存溢出

parent 8135970d
...@@ -40,6 +40,6 @@ public class SobotCommonApi { ...@@ -40,6 +40,6 @@ public class SobotCommonApi {
*/ */
public static void setShowLogDebug(boolean isDebug) { public static void setShowLogDebug(boolean isDebug) {
SobotLogUtils.setShowDebug(isDebug); SobotLogUtils.setShowDebug(isDebug);
SobotNetLogUtils.setShowDebug(true); SobotNetLogUtils.setShowDebug(isDebug);
} }
} }
...@@ -101,6 +101,12 @@ public class SobotNetLogUtils { ...@@ -101,6 +101,12 @@ public class SobotNetLogUtils {
public static void i(String str) { public static void i(String str) {
if (isDebug && allowI) { if (isDebug && allowI) {
String tag = generateTag(); String tag = generateTag();
if(str==null){
return;
}
if(str.length()>4*MAX_LENGTH){
str = str.substring(0,4*MAX_LENGTH);
}
StringBuilder content = new StringBuilder(str); StringBuilder content = new StringBuilder(str);
//采取分段打印日志的方法:当长度超过4000时,我们就来分段截取打印 //采取分段打印日志的方法:当长度超过4000时,我们就来分段截取打印
if (content.length() > MAX_LENGTH) { if (content.length() > MAX_LENGTH) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment