code: private String joinStrings(Collection<String> messages) {
          StringBuilder b = new StringBuilder();
          for (String s : messages) {
              if (s == null || s.isEmpty()) {
                  continue;
              }
  
              // Preserve new-lines in this event by replacing them
              // with "\r". Otherwise, they're processed as event
              // delimiters, resulting in unintentional multiple events.
              b.append(s.replaceAll("[\r\n]", "\r")).append('\n');
          }
          return b.toString();
      }
docs: Combines a collection of messages to be sent to Loggly.
  In order to preserve event boundaries, the new lines in
  each message are replaced with '\r', which get stripped
  by Loggly.
  @param messages messages to be combined
  @return a single string containing all the messages