diff -r fd2ac24c6a22 -r 5f745ae795a8 java/sql-dk/src/info/globalcode/sql/dk/logging/ColorfulConsoleFormatter.java --- a/java/sql-dk/src/info/globalcode/sql/dk/logging/ColorfulConsoleFormatter.java Wed Dec 25 01:23:27 2013 +0100 +++ b/java/sql-dk/src/info/globalcode/sql/dk/logging/ColorfulConsoleFormatter.java Wed Dec 25 02:04:57 2013 +0100 @@ -32,13 +32,15 @@ */ public class ColorfulConsoleFormatter extends Formatter { + private boolean printStacktrace = false; + @Override public String format(LogRecord r) { StringWriter sw = new StringWriter(); try (ColorfulPrintWriter out = new ColorfulPrintWriter(sw)) { printLevel(out, r.getLevel()); printMessage(out, r); - printThrowable(out, r.getThrown()); + printThrowable(out, r); out.println(); } return sw.toString(); @@ -46,7 +48,6 @@ private void printLevel(ColorfulPrintWriter out, Level l) { TerminalColor color = TerminalColor.Magenta; - TerminalStyle style; if (l == Level.SEVERE) { color = TerminalColor.Red; @@ -61,7 +62,8 @@ out.print(formatMessage(r)); } - private void printThrowable(ColorfulPrintWriter out, Throwable t) { + private void printThrowable(ColorfulPrintWriter out, LogRecord r) { + Throwable t = r.getThrown(); if (t != null) { out.print(": "); out.print(TerminalColor.Red, t.getClass().getSimpleName()); @@ -70,6 +72,21 @@ out.print(": "); out.print(message); } + if (printStacktrace) { + out.println(); + out.setForegroundColor(TerminalColor.Yellow); + out.setStyle(TerminalStyle.Dim); + t.printStackTrace(out); + out.resetAll(); + } } } + + public boolean isPrintStacktrace() { + return printStacktrace; + } + + public void setPrintStacktrace(boolean printStacktrace) { + this.printStacktrace = printStacktrace; + } }