本文整理汇总了Java中ch.qos.logback.classic.spi.StackTraceElementProxy类的典型用法代码示例。如果您正苦于以下问题:Java StackTraceElementProxy类的具体用法?Java StackTraceElementProxy怎么用?Java StackTraceElementProxy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StackTraceElementProxy类属于ch.qos.logback.classic.spi包,在下文中一共展示了StackTraceElementProxy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fullDump
import ch.qos.logback.classic.spi.StackTraceElementProxy; //导入依赖的package包/类
public String fullDump(ILoggingEvent evt) {
try {
IThrowableProxy proxy = evt.getThrowableProxy();
if(proxy == null)
return null;
StringBuilder builder = new StringBuilder();
for (StackTraceElementProxy step : proxy
.getStackTraceElementProxyArray()) {
String string = step.toString();
builder.append(CoreConstants.TAB).append(string);
ThrowableProxyUtil.subjoinPackagingData(builder, step);
builder.append(CoreConstants.LINE_SEPARATOR);
}
return builder.toString();
} catch(Exception e) {
addError("exception trying to log exception", e);
return "exception parsing exception";
}
}
示例2: appendThrowable
import ch.qos.logback.classic.spi.StackTraceElementProxy; //导入依赖的package包/类
private void appendThrowable(IThrowableProxy proxy, ILoggingEvent loggingEvent) {
//Append Exception Message
appendToLog(loggingEvent, String.format("%s: %s", proxy.getClassName(), proxy.getMessage()));
//Append Exception Stack Trace
for (StackTraceElementProxy element : loggingEvent.getThrowableProxy().getStackTraceElementProxyArray()) {
appendToLog(loggingEvent, "\t" + element.getSTEAsString());
}
if (proxy.getSuppressed().length > 0) {
appendToLog(loggingEvent, "Suppressed Exceptions:");
for (IThrowableProxy p : proxy.getSuppressed()) {
appendThrowable(p, loggingEvent);
}
}
if (proxy.getCause() != null) {
appendToLog(loggingEvent, "Cause:");
appendThrowable(proxy.getCause(), loggingEvent);
}
}
示例3: appendStackTrace
import ch.qos.logback.classic.spi.StackTraceElementProxy; //导入依赖的package包/类
private void appendStackTrace(StringBuilder log, ThrowableProxy proxy) {
if (proxy != null) {
Stream<StackTraceElementProxy> trace = Arrays.stream(proxy.getStackTraceElementProxyArray());
trace.forEach(step -> {
String string = step.toString();
log.append(CoreConstants.TAB).append(string);
ThrowableProxyUtil.subjoinPackagingData(log, step);
log.append(CoreConstants.LINE_SEPARATOR);
});
trace.close();
}
}
示例4: render
import ch.qos.logback.classic.spi.StackTraceElementProxy; //导入依赖的package包/类
void render(StringBuilder sbuf, IThrowableProxy tp) {
printFirstLine(sbuf, tp);
int commonFrames = tp.getCommonFrames();
StackTraceElementProxy[] stepArray = tp.getStackTraceElementProxyArray();
for (int i = 0; i < stepArray.length - commonFrames; i++) {
StackTraceElementProxy step = stepArray[i];
sbuf.append(TRACE_PREFIX);
sbuf.append(Transform.escapeTags(step.toString()));
sbuf.append(CoreConstants.LINE_SEPARATOR);
}
if (commonFrames > 0) {
sbuf.append(TRACE_PREFIX);
sbuf.append("\t... ").append(commonFrames).append(" common frames omitted").append(CoreConstants.LINE_SEPARATOR);
}
}
示例5: build
import ch.qos.logback.classic.spi.StackTraceElementProxy; //导入依赖的package包/类
public static LoggingInfo build(LoggingEvent loggingEvent) {
LoggingInfo loggingInfo = new LoggingInfo();
if (null != loggingEvent) {
loggingInfo.setMessage(loggingEvent.getMessage());
loggingInfo.setLevel(loggingEvent.getLevel().toString());
loggingInfo.setLoggerName(loggingEvent.getLoggerName());
loggingInfo.setThreadName(loggingEvent.getThreadName());
if (null != loggingEvent.getThrowableProxy()) {
loggingInfo.setExceptionName(loggingEvent.getThrowableProxy().getClassName());
loggingInfo.setExceptionMessage(loggingEvent.getThrowableProxy().getMessage());
StackTraceElementProxy[] stackTraces = loggingEvent.getThrowableProxy().getStackTraceElementProxyArray();
if (null != stackTraces && stackTraces.length > 0) {
loggingInfo.setTopStackTrace(stackTraces[0].getStackTraceElement().toString());
}
}
if (loggingEvent.hasCallerData()) {
StackTraceElement st = loggingEvent.getCallerData()[0];
loggingInfo.setCallerData(st.toString());
}
loggingInfo.setMdcProperty(loggingEvent.getMDCPropertyMap());
loggingInfo.setCreateTime(millisecondToDateTime(loggingEvent.getTimeStamp()));
}
return loggingInfo;
}
示例6: render
import ch.qos.logback.classic.spi.StackTraceElementProxy; //导入依赖的package包/类
void render(StringBuilder sbuf, IThrowableProxy tp) {
printFirstLine(sbuf, tp);
int commonFrames = tp.getCommonFrames();
StackTraceElementProxy[] stepArray = tp.getStackTraceElementProxyArray();
for (int i = 0; i < stepArray.length - commonFrames; i++) {
StackTraceElementProxy step = stepArray[i];
sbuf.append(TRACE_PREFIX);
sbuf.append(Transform.escapeTags(step.toString()));
sbuf.append(CoreConstants.LINE_SEPARATOR);
}
if (commonFrames > 0) {
sbuf.append(TRACE_PREFIX);
sbuf.append("\t... ").append(commonFrames).append(" common frames omitted")
.append(CoreConstants.LINE_SEPARATOR);
}
}
示例7: testAppendThrowable
import ch.qos.logback.classic.spi.StackTraceElementProxy; //导入依赖的package包/类
@Test
public void testAppendThrowable() throws Exception {
StringBuilder buf = new StringBuilder();
DummyThrowableProxy tp = new DummyThrowableProxy();
tp.setClassName("test1");
tp.setMessage("msg1");
StackTraceElement ste1 = new StackTraceElement("c1", "m1", "f1", 1);
StackTraceElement ste2 = new StackTraceElement("c2", "m2", "f2", 2);
StackTraceElementProxy[] stepArray = { new StackTraceElementProxy(ste1),
new StackTraceElementProxy(ste2) };
tp.setStackTraceElementProxyArray(stepArray);
DefaultThrowableRenderer renderer = (DefaultThrowableRenderer) layout
.getThrowableRenderer();
renderer.render(buf, tp);
System.out.println(buf.toString());
String[] result = buf.toString().split(CoreConstants.LINE_SEPARATOR);
System.out.println(result[0]);
assertEquals("test1: msg1", result[0]);
assertEquals(DefaultThrowableRenderer.TRACE_PREFIX + "at c1.m1(f1:1)", result[1]);
}
示例8: subjoinThrowableProxy
import ch.qos.logback.classic.spi.StackTraceElementProxy; //导入依赖的package包/类
void subjoinThrowableProxy(StringBuilder buf, IThrowableProxy tp) {
subjoinFirstLine(buf, tp);
buf.append(CoreConstants.LINE_SEPARATOR);
final StackTraceElementProxy[] stepArray = tp.getStackTraceElementProxyArray();
final int commonFrames = tp.getCommonFrames();
int maxIndex = stepArray.length;
if (commonFrames > 0) {
maxIndex -= commonFrames;
}
for (int i = 0; i < maxIndex; i++) {
final String string = stepArray[i].toString();
buf.append(PREFIX);
buf.append(string);
extraData(buf, stepArray[i]); // allow other data to be added
buf.append(CoreConstants.LINE_SEPARATOR);
}
if (commonFrames > 0) {
buf.append("!... ").append(tp.getCommonFrames()).append(
" common frames omitted").append(CoreConstants.LINE_SEPARATOR);
}
}
示例9: convertToStackTraces
import ch.qos.logback.classic.spi.StackTraceElementProxy; //导入依赖的package包/类
private List<StackTraceVO> convertToStackTraces(final IThrowableProxy throwableProxy) {
final StackTraceElementProxy[] stackTraceElementProxies = throwableProxy.getStackTraceElementProxyArray();
final List<StackTraceVO> stackTraces = Lists.newArrayList();
for (final StackTraceElementProxy stackTraceElementProxy : stackTraceElementProxies) {
final StackTraceElement stackTraceElement = stackTraceElementProxy.getStackTraceElement();
final StackTraceVO stackTrace = new StackTraceVO();
stackTrace.setMethod(stackTraceElement.getClassName() + "." + stackTraceElement.getMethodName());
stackTrace.setLineNumber(stackTraceElement.getLineNumber());
stackTrace.setFile(stackTraceElement.getFileName());
stackTrace.setInProject(configuration.isInProject(stackTraceElement.getClassName()));
stackTraces.add(stackTrace);
}
return stackTraces;
}
示例10: createThrowableData
import ch.qos.logback.classic.spi.StackTraceElementProxy; //导入依赖的package包/类
/**
* fluentdサーバに転送するログデータに格納する例外情報を生成する。
*
* @param th 例外データ。
* @return 例外情報。
*/
private Map<String, Object> createThrowableData(IThrowableProxy th) {
Map<String, Object> data = new LinkedHashMap<>();
data.put("className", th.getClassName());
data.put("message", th.getMessage());
List<String> stackTrace = new ArrayList<>();
for (StackTraceElementProxy ste : th.getStackTraceElementProxyArray()) {
stackTrace.add(ste.toString());
}
data.put("stackTrace", stackTrace);
if (th.getCause() != null) {
data.put("cause", createThrowableData(th.getCause()));
}
return data;
}
示例11: toProto
import ch.qos.logback.classic.spi.StackTraceElementProxy; //导入依赖的package包/类
private static Proto.Throwable toProto(IThrowableProxy t) {
Proto.Throwable.Builder builder = Proto.Throwable.newBuilder()
.setClassName(t.getClassName());
String message = t.getMessage();
if (message != null) {
builder.setMessage(message);
}
for (StackTraceElementProxy element : t.getStackTraceElementProxyArray()) {
builder.addStackTraceElement(ErrorMessage.toProto(element.getStackTraceElement()));
}
builder.setFramesInCommonWithEnclosing(t.getCommonFrames());
IThrowableProxy cause = t.getCause();
if (cause != null) {
builder.setCause(toProto(cause));
}
for (IThrowableProxy suppressed : t.getSuppressed()) {
builder.addSuppressed(toProto(suppressed));
}
return builder.build();
}
示例12: fullDump
import ch.qos.logback.classic.spi.StackTraceElementProxy; //导入依赖的package包/类
private String fullDump(StackTraceElementProxy[] stackTraceElementProxyArray) {
StringBuilder builder = new StringBuilder();
for (StackTraceElementProxy step : stackTraceElementProxyArray) {
builder.append(CoreConstants.LINE_SEPARATOR);
String string = step.toString();
builder.append(CoreConstants.TAB).append(string);
ThrowableProxyUtil.subjoinPackagingData(builder, step);
}
return builder.toString();
}
示例13: dump
import ch.qos.logback.classic.spi.StackTraceElementProxy; //导入依赖的package包/类
private String dump(IThrowableProxy throwableProxy) {
StringBuilder builder = new StringBuilder();
builder.append(throwableProxy.getClassName()).append(": ").append(throwableProxy.getMessage()).append(CoreConstants.LINE_SEPARATOR);
for (StackTraceElementProxy step : throwableProxy.getStackTraceElementProxyArray()) {
String string = step.toString();
builder.append(CoreConstants.TAB).append(string);
ThrowableProxyUtil.subjoinPackagingData(builder, step);
builder.append(CoreConstants.LINE_SEPARATOR);
}
return builder.toString();
}
示例14: DefaultLogThrowable
import ch.qos.logback.classic.spi.StackTraceElementProxy; //导入依赖的package包/类
DefaultLogThrowable(IThrowableProxy throwableProxy) {
this.className = throwableProxy.getClassName();
this.message = throwableProxy.getMessage();
StackTraceElementProxy[] stackTraceElementProxyArray = throwableProxy.getStackTraceElementProxyArray();
this.stackTraces = new StackTraceElement[stackTraceElementProxyArray.length];
for (int i = 0; i < stackTraceElementProxyArray.length; i++) {
stackTraces[i] = stackTraceElementProxyArray[i].getStackTraceElement();
}
cause = (throwableProxy.getCause() == null) ? null : new DefaultLogThrowable(throwableProxy.getCause());
}
示例15: getStackTrace
import ch.qos.logback.classic.spi.StackTraceElementProxy; //导入依赖的package包/类
@Override
public StackTraceElement[] getStackTrace() {
final StackTraceElementProxy[] elements = proxy.getStackTraceElementProxyArray();
if (elements == null) {
return null;
}
final StackTraceElement[] result = new StackTraceElement[elements.length];
for (int i = 0; i < elements.length; i++) {
result[i] = elements[i].getStackTraceElement();
}
return result;
}