LogUtil { public static void logThrowable(Log log, String message, Throwable t) { final StringWriter stringWriter = new StringWriter(); final PrintWriter printWriter = new PrintWriter(stringWriter); printWriter.println(message); t.printStackTrace(printWriter); if (t.getCause() != null) { printWriter.println("Cause: " + t.getCause().getMessage()); t.getCause().printStackTrace(printWriter); } log.onErrorEvent(stringWriter.toString()); }  static void logThrowable(Log log, String message, Throwable t); static void logThrowable(SessionID sessionID, String message, Throwable t);  }
@Test public void testLogThrowable() throws ConfigError, FieldConvertError { ByteArrayOutputStream data = new ByteArrayOutputStream(); LogFactory mockLogFactory = createLogFactory(data); createSessionAndGenerateException(mockLogFactory); String message = new String(data.toByteArray()); assertTrue(message.contains("IOException")); }