fix(log): quote replacement for formatted log
ci/woodpecker/push/woodpecker Pipeline was successful
Details
ci/woodpecker/push/woodpecker Pipeline was successful
Details
This commit is contained in:
parent
0ae082e7d0
commit
7e136cbec5
|
@ -6,6 +6,7 @@ import org.jetbrains.annotations.Nullable;
|
|||
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
public interface Logger {
|
||||
static Logger forName(@NotNull String name) {
|
||||
|
@ -90,13 +91,13 @@ public interface Logger {
|
|||
}
|
||||
|
||||
default String format(String format, Object arg) {
|
||||
return format.replaceFirst("\\{}", StringFormatter.toString(arg));
|
||||
return format.replaceFirst("\\{}", Matcher.quoteReplacement(StringFormatter.toString(arg)));
|
||||
}
|
||||
|
||||
default String format(String format, Object... args) {
|
||||
if (args == null || format == null) return format;
|
||||
for (Object arg : args) {
|
||||
format = format.replaceFirst("\\{}", StringFormatter.toString(arg));
|
||||
format = format.replaceFirst("\\{}", Matcher.quoteReplacement(StringFormatter.toString(arg)));
|
||||
}
|
||||
return format;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue