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 ( ' ' ) ; } return b . toString ( ) ; }
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 .