All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.ebeaninternal.server.persist.TrimLogSql Maven / Gradle / Ivy

package io.ebeaninternal.server.persist;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Utility to improve logging of raw SQL that contains new line characters.
 */
public class TrimLogSql {

  /**
   * Statically compiled Regex, to avoid having it be compiled every time it is used.
   */
  private static final Pattern LINUX_NEW_LINE_REPLACE_PATTERN = Pattern.compile("\n", Pattern.LITERAL);

  /**
   * Replace new line chars for nicer logging of multi-line sql strings.
   */
  public static String trim(String sql) {
    return LINUX_NEW_LINE_REPLACE_PATTERN.matcher(sql).replaceAll(Matcher.quoteReplacement("\\n "));
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy