Beispiel #1
0
  @SuppressWarnings("ThrowableResultOfMethodCallIgnored" /* Throwable is logged */)
  public void log(final Message message, @Nullable final Throwable t) {
    final Element typeElement = doc.createElement(message.getType().toString());

    final Element messageElement = doc.createElement("message");
    messageElement.setTextContent(message.toString());
    typeElement.appendChild(messageElement);

    if (t != null) {
      final Element throwableElement = doc.createElement("throwable");

      final Element throwableMessageElement = doc.createElement("message");
      throwableMessageElement.setTextContent(t.getMessage());
      throwableElement.appendChild(throwableMessageElement);

      final StringWriter stringWriter = new StringWriter();
      final PrintWriter printWriter = new PrintWriter(stringWriter);

      t.printStackTrace(printWriter);
      printWriter.flush();

      final Element stacktraceElement = doc.createElement("stacktrace");
      stacktraceElement.setTextContent(stringWriter.toString());
      throwableElement.appendChild(stacktraceElement);

      typeElement.appendChild(throwableElement);
    }

    messages.appendChild(typeElement);
  }
Beispiel #2
0
 public void logMessage(
     final Update update, final RpslAttribute attribute, final Message message) {
   final Element updateElement = createOrGetUpdateElement(update);
   updateElement.appendChild(
       keyValue(
           "message",
           MessageFormat.format(
               "{0} (in attribute [{1}])", message.toString(), attribute.toString())));
 }
Beispiel #3
0
 public MessageObject(final Message message) {
   this(message.toString());
 }
Beispiel #4
0
 public void logMessage(final Update update, final Message message) {
   final Element updateElement = createOrGetUpdateElement(update);
   updateElement.appendChild(keyValue("message", message.toString()));
 }
Beispiel #5
0
 public static String print(final Message message) {
   return prettyPrint(
       String.format("***%s: ", message.getType()), message.getFormattedText(), 12, 80);
 }