mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-17 22:56:28 +00:00
Bit of cleanup suggestions from intellij. (#1168)
This commit is contained in:
1 parent
2c5bf98d0b
commit
4879d44da4
10 files changed
+147
-25
No files matched your search
@@ -1,14 +1,22 @@
|
||||
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 sql.replace("\n", "\\n ");
|
||||
return LINUX_NEW_LINE_REPLACE_PATTERN.matcher(sql).replaceAll(Matcher.quoteReplacement("\\n "));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user