[main] Split formatting for Throwable from formatter with message
This commit is contained in:
parent
846766e3de
commit
fb930b5979
|
@ -100,13 +100,17 @@ public interface Logger {
|
|||
|
||||
default String format(String msg, Throwable t) {
|
||||
if (t == null) return msg;
|
||||
return msg + System.lineSeparator() + format(t);
|
||||
}
|
||||
|
||||
default String format(Throwable t) {
|
||||
try (ByteArrayOutputStream baot = new ByteArrayOutputStream()) {
|
||||
try (PrintStream ps = new PrintStream(baot, true)) {
|
||||
t.printStackTrace(ps);
|
||||
}
|
||||
return msg + System.lineSeparator() + baot;
|
||||
return baot.toString();
|
||||
} catch (IOException e) {
|
||||
return msg + System.lineSeparator() + t;
|
||||
return t.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue