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); } }
public void calculate(IThrowableProxy tp) { while (tp != null) { populateFrames(tp.getStackTraceElementProxyArray()); IThrowableProxy[] suppressed = tp.getSuppressed(); if (suppressed != null) { for (IThrowableProxy current : suppressed) { populateFrames(current.getStackTraceElementProxyArray()); } } tp = tp.getCause(); } }
short buildExceptionStatement(IThrowableProxy tp, short baseIndex, PreparedStatement insertExceptionStatement, long eventId) throws SQLException { StringBuilder buf = new StringBuilder(); ThrowableProxyUtil.subjoinFirstLine(buf, tp); updateExceptionStatement(insertExceptionStatement, buf.toString(), baseIndex++, eventId); int commonFrames = tp.getCommonFrames(); StackTraceElementProxy[] stepArray = tp.getStackTraceElementProxyArray(); for (int i = 0; i < stepArray.length - commonFrames; i++) { StringBuilder sb = new StringBuilder(); sb.append(CoreConstants.TAB); ThrowableProxyUtil.subjoinSTEP(sb, stepArray[i]); updateExceptionStatement(insertExceptionStatement, sb.toString(), baseIndex++, eventId); } if (commonFrames > 0) { StringBuilder sb = new StringBuilder(); sb.append(CoreConstants.TAB).append("... ").append(commonFrames).append(" common frames omitted"); updateExceptionStatement(insertExceptionStatement, sb.toString(), baseIndex++, eventId); } return baseIndex; }
/** * @param sb The StringBuilder the STEPs are appended to. * @param indentLevel indentation level used for the STEPs, usually REGULAR_EXCEPTION_INDENT. * @param tp the IThrowableProxy containing the STEPs. */ public static void subjoinSTEPArray(StringBuilder sb, int indentLevel, IThrowableProxy tp) { StackTraceElementProxy[] stepArray = tp.getStackTraceElementProxyArray(); int commonFrames = tp.getCommonFrames(); for (int i = 0; i < stepArray.length - commonFrames; i++) { StackTraceElementProxy step = stepArray[i]; indent(sb, indentLevel); subjoinSTEP(sb, step); sb.append(CoreConstants.LINE_SEPARATOR); } if (commonFrames > 0) { indent(sb, indentLevel); sb.append("... ").append(commonFrames).append(" common frames omitted").append(CoreConstants.LINE_SEPARATOR); } }
@Override protected void postProcess(Object eventObject, OutputStream sw) { if (throwableExcluded) return; ILoggingEvent event = (ILoggingEvent) eventObject; IThrowableProxy tp = event.getThrowableProxy(); if (tp == null) return; String stackTracePrefix = stackTraceLayout.doLayout(event); boolean isRootException = true; while (tp != null) { StackTraceElementProxy[] stepArray = tp.getStackTraceElementProxyArray(); try { handleThrowableFirstLine(sw, tp, stackTracePrefix, isRootException); isRootException = false; for (StackTraceElementProxy step : stepArray) { StringBuilder sb = new StringBuilder(); sb.append(stackTracePrefix).append(step); sw.write(sb.toString().getBytes()); sw.flush(); } } catch (IOException e) { break; } tp = tp.getCause(); } }
StackTraceElementProxy[] stepArray = tp.getStackTraceElementProxyArray(); buf.append(" <log4j:throwable><![CDATA["); for (StackTraceElementProxy step : stepArray) {
protected void subjoinSTEPArray(StringBuilder buf, int indent, IThrowableProxy tp) { StackTraceElementProxy[] stepArray = tp.getStackTraceElementProxyArray(); int commonFrames = tp.getCommonFrames();
@InternalApi("Visible for testing") static void writeStack(IThrowableProxy throwProxy, String prefix, StringBuilder payload) { if (throwProxy == null) { return; } payload .append(prefix) .append(throwProxy.getClassName()) .append(": ") .append(throwProxy.getMessage()) .append('\n'); StackTraceElementProxy[] trace = throwProxy.getStackTraceElementProxyArray(); if (trace == null) { trace = new StackTraceElementProxy[0]; } int commonFrames = throwProxy.getCommonFrames(); int printFrames = trace.length - commonFrames; for (int i = 0; i < printFrames; i++) { payload.append(" ").append(trace[i]).append('\n'); } if (commonFrames != 0) { payload.append(" ... ").append(commonFrames).append(" common frames elided\n"); } writeStack(throwProxy.getCause(), "caused by: ", payload); }
public static ThrowableProxyVO build(IThrowableProxy throwableProxy) { if (throwableProxy == null) { return null; } ThrowableProxyVO tpvo = new ThrowableProxyVO(); tpvo.className = throwableProxy.getClassName(); tpvo.message = throwableProxy.getMessage(); tpvo.commonFramesCount = throwableProxy.getCommonFrames(); tpvo.stackTraceElementProxyArray = throwableProxy.getStackTraceElementProxyArray(); IThrowableProxy cause = throwableProxy.getCause(); if (cause != null) { tpvo.cause = ThrowableProxyVO.build(cause); } IThrowableProxy[] suppressed = throwableProxy.getSuppressed(); if (suppressed != null) { tpvo.suppressed = new IThrowableProxy[suppressed.length]; for (int i = 0; i < suppressed.length; i++) { tpvo.suppressed[i] = ThrowableProxyVO.build(suppressed[i]); } } return tpvo; } }
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); } }
public void calculate(IThrowableProxy tp) { while (tp != null) { populateFrames(tp.getStackTraceElementProxyArray()); IThrowableProxy[] suppressed = tp.getSuppressed(); if(suppressed != null) { for(IThrowableProxy current:suppressed) { populateFrames(current.getStackTraceElementProxyArray()); } } tp = tp.getCause(); } }
/** * @param sb The StringBuilder the STEPs are appended to. * @param indentLevel indentation level used for the STEPs, usually REGULAR_EXCEPTION_INDENT. * @param tp the IThrowableProxy containing the STEPs. */ public static void subjoinSTEPArray(StringBuilder sb, int indentLevel, IThrowableProxy tp) { StackTraceElementProxy[] stepArray = tp.getStackTraceElementProxyArray(); int commonFrames = tp.getCommonFrames(); for (int i = 0; i < stepArray.length - commonFrames; i++) { StackTraceElementProxy step = stepArray[i]; indent(sb, indentLevel); subjoinSTEP(sb, step); sb.append(CoreConstants.LINE_SEPARATOR); } if (commonFrames > 0) { indent(sb, indentLevel); sb.append("... ").append(commonFrames).append(" common frames omitted") .append(CoreConstants.LINE_SEPARATOR); } }
@Override protected void postProcess(Object eventObject, OutputStream sw) { if (throwableExcluded) return; ILoggingEvent event = (ILoggingEvent) eventObject; IThrowableProxy tp = event.getThrowableProxy(); if (tp == null) return; String stackTracePrefix = stackTraceLayout.doLayout(event); boolean isRootException = true; while (tp != null) { StackTraceElementProxy[] stepArray = tp.getStackTraceElementProxyArray(); try { handleThrowableFirstLine(sw, tp, stackTracePrefix, isRootException); isRootException = false; for (StackTraceElementProxy step : stepArray) { StringBuilder sb = new StringBuilder(); sb.append(stackTracePrefix).append(step); sw.write(sb.toString().getBytes()); sw.flush(); } } catch (IOException e) { break; } tp = tp.getCause(); } }
short buildExceptionStatement(IThrowableProxy tp, short baseIndex, PreparedStatement insertExceptionStatement, long eventId) throws SQLException { StringBuilder buf = new StringBuilder(); ThrowableProxyUtil.subjoinFirstLine(buf, tp); updateExceptionStatement(insertExceptionStatement, buf.toString(), baseIndex++, eventId); int commonFrames = tp.getCommonFrames(); StackTraceElementProxy[] stepArray = tp.getStackTraceElementProxyArray(); for (int i = 0; i < stepArray.length - commonFrames; i++) { StringBuilder sb = new StringBuilder(); sb.append(CoreConstants.TAB); ThrowableProxyUtil.subjoinSTEP(sb, stepArray[i]); updateExceptionStatement(insertExceptionStatement, sb.toString(), baseIndex++, eventId); } if (commonFrames > 0) { StringBuilder sb = new StringBuilder(); sb.append(CoreConstants.TAB).append("... ").append(commonFrames).append( " common frames omitted"); updateExceptionStatement(insertExceptionStatement, sb.toString(), baseIndex++, eventId); } return baseIndex; }
protected void subjoinSTEPArray(StringBuilder buf, int indent, IThrowableProxy tp) { StackTraceElementProxy[] stepArray = tp.getStackTraceElementProxyArray(); int commonFrames = tp.getCommonFrames(); boolean unrestrictedPrinting = lengthOption > stepArray.length; int maxIndex = (unrestrictedPrinting) ? stepArray.length : lengthOption; if (commonFrames > 0 && unrestrictedPrinting) { maxIndex -= commonFrames; } for (int i = 0; i < maxIndex; i++) { ThrowableProxyUtil.indent(buf, indent); buf.append(stepArray[i]); extraData(buf, stepArray[i]); // allow other data to be added buf.append(CoreConstants.LINE_SEPARATOR); } if (commonFrames > 0 && unrestrictedPrinting) { ThrowableProxyUtil.indent(buf, indent); buf.append("... ").append(tp.getCommonFrames()).append( " common frames omitted").append(CoreConstants.LINE_SEPARATOR); } } }
StackTraceElementProxy[] stepArray = tp.getStackTraceElementProxyArray(); buf.append(" <log4j:throwable><![CDATA["); for (StackTraceElementProxy step : stepArray) {
public static ThrowableProxyVO build(IThrowableProxy throwableProxy) { if(throwableProxy == null) { return null; } ThrowableProxyVO tpvo = new ThrowableProxyVO(); tpvo.className = throwableProxy.getClassName(); tpvo.message = throwableProxy.getMessage(); tpvo.commonFramesCount = throwableProxy.getCommonFrames(); tpvo.stackTraceElementProxyArray = throwableProxy.getStackTraceElementProxyArray(); IThrowableProxy cause = throwableProxy.getCause(); if(cause != null) { tpvo.cause = ThrowableProxyVO.build(cause); } IThrowableProxy[] suppressed = throwableProxy.getSuppressed(); if(suppressed != null) { tpvo.suppressed = new IThrowableProxy[suppressed.length]; for(int i = 0;i<suppressed.length;i++) { tpvo.suppressed[i] = ThrowableProxyVO.build(suppressed[i]); } } return tpvo; } }
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(); } }
public void calculate(IThrowableProxy tp) { while (tp != null) { populateFrames(tp.getStackTraceElementProxyArray()); IThrowableProxy[] suppressed = tp.getSuppressed(); if(suppressed != null) { for(IThrowableProxy current:suppressed) { populateFrames(current.getStackTraceElementProxyArray()); } } tp = tp.getCause(); } }
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()); }