class LoggingHelper {

  public static String concatCollectionToStringForLogging(Collection<String> collection, String delimiter) {
    if (collection == null) {
      return "";
    }
    if (delimiter == null) {
      delimiter = ",";
    }
    StringBuilder bldr = new StringBuilder();
    int totalLen = 0;
    int delimiterSize = delimiter.length();
    for (String str : collection) {
      if (totalLen > MAX_LOG_STRING_LEN) break;
      if (str.length() + totalLen > MAX_LOG_STRING_LEN) {
        bldr.append(str.subSequence(0, (MAX_LOG_STRING_LEN-totalLen)));
        break;
      } else {
        bldr.append(str);
        bldr.append(delimiter);
        totalLen += str.length() + delimiterSize;
      }
    }
    return bldr.toString();
  }

  private  LoggingHelper();

}