class 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());
    }

}