Java Code Examples for ch.qos.logback.classic.spi.IThrowableProxy#getCommonFrames()

The following examples show how to use ch.qos.logback.classic.spi.IThrowableProxy#getCommonFrames() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PrefixedThrowableProxyConverter.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
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);
    }
}
 
Example 2
Source File: StructuredLoggingEncoder.java    From flo with Apache License 2.0 6 votes vote down vote up
private static void writeStack(StringBuilder sb, IThrowableProxy t, String caption, int indent, String linebreak) {
  if (t == null) {
    return;
  }
  indent(sb, indent).append(caption).append(t.getClassName()).append(": ").append(t.getMessage()).append(linebreak);
  final StackTraceElementProxy[] trace = t.getStackTraceElementProxyArray();
  if (trace != null) {
    int commonFrames = t.getCommonFrames();
    int printFrames = trace.length - commonFrames;
    for (int i = 0; i < printFrames; i++) {
      indent(sb, indent).append("\t").append(trace[i]).append(linebreak);
    }
    if (commonFrames != 0) {
      indent(sb, indent).append("\t... ").append(commonFrames).append(" more").append(linebreak);
    }
    final IThrowableProxy[] suppressed = t.getSuppressed();
    for (IThrowableProxy st : suppressed) {
      writeStack(sb, st, "Suppressed: ", indent + 1, linebreak);
    }
  }

  writeStack(sb, t.getCause(), "Caused by: ", indent, linebreak);
}
 
Example 3
Source File: PrefixedThrowableProxyConverter.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
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);
    }
}
 
Example 4
Source File: NSThrowableConvert.java    From ns4_frame with Apache License 2.0 5 votes vote down vote up
@Override
public void subjoinSTEPArray(StringBuilder buf, int indent, IThrowableProxy tp) {
    String totalKey = LogKey.getTotalKey();
    StackTraceElementProxy[] stepArray = tp.getStackTraceElementProxyArray();
    int commonFrames = tp.getCommonFrames();

    boolean unrestrictedPrinting = Integer.MAX_VALUE > stepArray.length;


    int maxIndex = (unrestrictedPrinting) ? stepArray.length : Integer.MAX_VALUE;
    if (commonFrames > 0 && unrestrictedPrinting) {
        maxIndex -= commonFrames;
    }

    for (int i = 0; i < maxIndex; i++) {
        buf.append(totalKey);
        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) {
        buf.append(totalKey);
        ThrowableProxyUtil.indent(buf, indent);
        buf.append("... ").append(tp.getCommonFrames()).append(
                " common frames omitted").append(CoreConstants.LINE_SEPARATOR);
    }
}
 
Example 5
Source File: ExceptionUtil.java    From cloudwatch-logback-appender with Apache License 2.0 5 votes vote down vote up
private  static void appendStackTrace(StringBuilder sb, String prefix, IThrowableProxy aProxy) {

        StackTraceElementProxy[] frames = aProxy.getStackTraceElementProxyArray();
        int commonFrames = aProxy.getCommonFrames();
        for(int i=0, size=frames.length-commonFrames; i<size; ++i) {
            sb.append(prefix+frames[i]+"\n");
        }
        if (commonFrames>0) {
            sb.append(prefix+"... "+commonFrames+" more"+"\n");
        }
    }
 
Example 6
Source File: PrefixedThrowableProxyConverter.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
private void subjoinFirstLine(StringBuilder buf, IThrowableProxy tp) {
    final int commonFrames = tp.getCommonFrames();
    if (commonFrames > 0) {
        buf.append(CoreConstants.CAUSED_BY);
    }
    subjoinExceptionMessage(buf, tp);
}
 
Example 7
Source File: PrefixedThrowableProxyConverter.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
private void subjoinFirstLine(StringBuilder buf, IThrowableProxy tp) {
    final int commonFrames = tp.getCommonFrames();
    if (commonFrames > 0) {
        buf.append(CoreConstants.CAUSED_BY);
    }
    subjoinExceptionMessage(buf, tp);
}