buffer.addLine().indent(5).addJsonFieldName("message") .asJsonString(ex.getMessage()).addLine(','); buffer.addLine().indent(5).addJsonFieldName("exception") .asJsonString(ex.getClass().getSimpleName()).addLine(','); buffer.addLine().indent(5).addJsonFieldName("causeMessage") .asJsonString(ex.getCause().getMessage()).addLine(','); buffer.addLine().indent(5).addJsonFieldName("cause2Message") .asJsonString(ex.getCause().getCause().getMessage()).addLine(','); buffer.addLine().indent(5).addJsonFieldName("cause3Message") .asJsonString(ex.getCause().getCause().getCause().getMessage()).addLine(','); buffer.addLine().indent(5).addJsonFieldName("cause4Message") .asJsonString(ex.getCause().getCause().getCause().getCause().getMessage()).addLine(','); buffer.addLine().indent(5).addJsonFieldName("stackTrace").addLine(); buffer.addLine().indent(5).addJsonFieldName("fullStackTrace").addLine();
public static void stackTraceToJson(CharBuf buffer, StackTraceElement[] stackTrace) { if (stackTrace.length == 0) { buffer.addLine("[]"); return; } buffer.multiply(' ', 16).addLine('['); for (int index = 0; index < stackTrace.length; index++) { StackTraceElement element = stackTrace[index]; if (element.getClassName().contains("Exceptions")) { continue; } buffer.indent(17).add("[ ").asJsonString(element.getMethodName()) .add(','); buffer.indent(3).asJsonString(element.getClassName()); if (element.getLineNumber() > 0) { buffer.add(","); buffer.indent(3).asJsonString("" + element.getLineNumber()) .addLine(" ],"); } else { buffer.addLine(" ],"); } } buffer.removeLastChar(); //trailing \n buffer.removeLastChar(); //trailing , buffer.addLine().multiply(' ', 15).add(']'); }
/** * Prints an Object and then terminates the line. This method calls * at first String.valueOf(x) to get the printed object's string value, * then behaves as * though it invokes <code>{@link #print(String)}</code> and then * <code>{@link #println()}</code>. * * @param message The <code>Object</code> to be printed. */ public void println(String message) { this.addLine(message); }
/** * Prints an Object and then terminates the line. This method calls * at first String.valueOf(x) to get the printed object's string value, * then behaves as * though it invokes <code>{@link #print(String)}</code> and then * <code>{@link #println()}</code>. * * @param message The <code>Object</code> to be printed. */ public void println(String message) { this.addLine(message); }
public void println() { this.addLine(); }
public PrintWriter printf(Locale l, String format, Object ... args) { this.addLine(String.format(l, format, args)); return this; }
public PrintWriter printf(String format, Object ... args) { this.addLine(String.format(format, args)); return this; }
public PrintWriter printf(String format, Object ... args) { this.addLine(String.format(format, args)); return this; }
public PrintWriter printf(Locale l, String format, Object ... args) { this.addLine(String.format(l, format, args)); return this; }
/** * Prints a String and then terminates the line. This method behaves as * though it invokes <code>{@link #print(String)}</code> and then * <code>{@link #println()}</code>. * * @param object the <code>String</code> value to be printed */ public void println(Object object) { this.addLine(Str.toString(object)); }
public void println(char x) { this.addChar(x).addLine(); }
public void println(double x) { add(x).addLine(); }
/** * Prints a String and then terminates the line. This method behaves as * though it invokes <code>{@link #print(String)}</code> and then * <code>{@link #println()}</code>. * * @param object the <code>String</code> value to be printed */ public void println(Object object) { this.addLine(Str.toString(object)); }
public void println(int x) { this.addInt(x).addLine(); }
public void println(long x) { this.addLong(x).addLine(); }
public void println(float x) { add(x).addLine(); }
public void println(float x) { add(x).addLine(); }
public void println(char x[]) { add(x).addLine(); }
public static String toString( Exception ex ) { CharBuf buffer = CharBuf.create( 255 ); buffer.addLine( ex.getLocalizedMessage() ); final StackTraceElement[] stackTrace = ex.getStackTrace(); for ( StackTraceElement element : stackTrace ) { buffer.add( element.getClassName() ); Str.sputs(" ", buffer, "class", element.getClassName(), "method", element.getMethodName(), "line", element.getLineNumber()); } return buffer.toString(); }
public static String toString( Exception ex ) { CharBuf buffer = CharBuf.create( 255 ); buffer.addLine( ex.getLocalizedMessage() ); final StackTraceElement[] stackTrace = ex.getStackTrace(); for ( StackTraceElement element : stackTrace ) { buffer.add( element.getClassName() ); Str.sputs(" ", buffer, "class", element.getClassName(), "method", element.getMethodName(), "line", element.getLineNumber()); } return buffer.toString(); }