build: logs refactor
This commit is contained in:
parent
a79e87ff87
commit
5fce7ee1c2
|
@ -24,7 +24,7 @@ public abstract class TestElementDTO {
|
|||
private String clazzName = TestElementDTO.class.getCanonicalName();
|
||||
|
||||
// 当前组件唯一标示
|
||||
private String resourceId;
|
||||
private String uuid;
|
||||
|
||||
// 组件标签名称
|
||||
private String name;
|
||||
|
@ -36,7 +36,7 @@ public abstract class TestElementDTO {
|
|||
private String index;
|
||||
|
||||
// 是否禁用/启用标示
|
||||
private boolean enable = true;
|
||||
private boolean enable;
|
||||
|
||||
// 子组件
|
||||
private LinkedList<TestElementDTO> hashTree;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package io.metersphere.sdk.util;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -200,15 +201,12 @@ public class LogUtils {
|
|||
* @return
|
||||
*/
|
||||
private static String getLogClass() {
|
||||
String str = "";
|
||||
|
||||
StackTraceElement[] stack = (new Throwable()).getStackTrace();
|
||||
if (stack.length > 3) {
|
||||
StackTraceElement ste = stack[3];
|
||||
str = ste.getClassName();// 类名称
|
||||
return ste.getClassName();
|
||||
}
|
||||
|
||||
return str;
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -217,19 +215,15 @@ public class LogUtils {
|
|||
* @return
|
||||
*/
|
||||
private static String getLogMethod() {
|
||||
String str = "";
|
||||
|
||||
StackTraceElement[] stack = (new Throwable()).getStackTrace();
|
||||
if (stack.length > 4) {
|
||||
if (ArrayUtils.isNotEmpty(stack) && stack.length > 4) {
|
||||
StackTraceElement ste = stack[4];
|
||||
str = "Method[" + ste.getMethodName() + "]";// 方法名称
|
||||
return "Method[" + ste.getMethodName() + "]";
|
||||
}
|
||||
|
||||
return str;
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
|
||||
public static String toString(Throwable e) {
|
||||
|
||||
try (StringWriter sw = new StringWriter();
|
||||
PrintWriter pw = new PrintWriter(sw);) {
|
||||
//将出错的栈信息输出到printWriter中
|
||||
|
@ -241,15 +235,4 @@ public class LogUtils {
|
|||
return ex.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
public static String getExceptionDetailsToStr(Exception e) {
|
||||
StringBuilder sb = new StringBuilder(e.toString());
|
||||
StackTraceElement[] stackElements = e.getStackTrace();
|
||||
for (StackTraceElement stackTraceElement : stackElements) {
|
||||
sb.append(stackTraceElement.toString());
|
||||
sb.append(StringUtils.LF);
|
||||
}
|
||||
sb.append(StringUtils.LF);
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue