Browse Source

REPORT-14869 10.0.3埋点

* commit '7ff2d8ca71479e3a912d27de56e347cb9314266b':
  REPORT-14869 10.0.3埋点 错误信息收集,增加堆栈记录(至多记录15行)
research/10.0
Alex.Sung 6 years ago
parent
commit
ffe282c366
  1. 10
      designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java
  2. 16
      designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java

10
designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java

@ -25,6 +25,7 @@ public class ErrorInfo {
private String templateid;
private String logid;
private String log;
private String stackTrace;
public ErrorInfo(String username, String uuid, String activekey) {
this.username = username;
@ -89,6 +90,14 @@ public class ErrorInfo {
this.log = log;
}
public String getStackTrace() {
return stackTrace;
}
public void setStackTrace(String stackTrace) {
this.stackTrace = stackTrace;
}
private String dateToString(){
DateFormat df = FRContext.getDefaultValues().getDateTimeFormat();
return df.format(new Date());
@ -107,6 +116,7 @@ public class ErrorInfo {
jo.put("uploadtime", uploadtime);
jo.put("logid", logid);
jo.put("log", log);
jo.put("stackTrace", stackTrace);
saveFileToCache(jo);
}

16
designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java

@ -30,6 +30,7 @@ import java.io.InputStream;
public class ErrorInfoLogAppender extends AppenderSkeleton {
private static final int ERROR_LEN = 8;
private static final int ERROR_STACK_TRACE = 15;
// 缓存下不变的, 没必要频繁取.
private String username;
@ -73,10 +74,25 @@ public class ErrorInfoLogAppender extends AppenderSkeleton {
errorInfo.setTemplateid(templateid);
errorInfo.setLog(msg);
errorInfo.setLogid(logid);
errorInfo.setStackTrace(readStackTrace(event));
errorInfo.saveAsJSON();
}
}
private String readStackTrace(LoggingEvent event) {
String[] s = event.getThrowableStrRep();
StringBuilder sb = new StringBuilder();
if(s != null){
int len = s.length;
for (int i = 0; i < len; i++) {
if(i < ERROR_STACK_TRACE){
sb.append(s[i]).append("\n");
}
}
}
return sb.toString();
}
private String readLogID(String log) {
String errorCode = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Engine_ErrorCode_Prefix");
// 报错信息国际化不规范, 有些是中文分号, 有些是英文

Loading…
Cancel
Save