private String formatLogLine(final int messageLevel, final Date messageDate,
      final String connectionName, final String threadName, final long threadId,
      final String message, final String exceptionText) {
    StringWriter stringWriter = new StringWriter();
    PrintWriter printWriter = new PrintWriter(stringWriter);

    printHeader(printWriter, messageLevel, messageDate, connectionName, threadName, threadId);

    if (message != null) {
      try {
        formatText(printWriter, message, 40);
      } catch (RuntimeException e) {
        printWriter.println(message);
        printWriter.println("Ignoring exception: ");
        e.printStackTrace(printWriter);
      }
    } else {
      printWriter.println();
    }
    if (exceptionText != null) {
      printWriter.print(exceptionText);
    }
    printWriter.close();
    try {
      stringWriter.close();
    } catch (IOException ignore) {
      // ignored
    }

    return stringWriter.toString();
  }
Logs a message and an exception to the specified log destination.

@param messageLevel a string representation of the level
@param messageId the actual message to log
@param throwable the actual Exception to log
geode-core/src/main/java/org/apache/geode/internal/logging/PureLogWriter.java