MCPcopy
hub / github.com/Col-E/Recaf / compile

Method compile

src/main/java/me/coley/recaf/util/Log.java:156–169  ·  view source on GitHub ↗

Compiles message with "{}" arg patterns. @param msg Message pattern. @param args Values to pass. @return Compiled message with inlined arg values.

(String msg, Object[] args)

Source from the content-addressed store, hash-verified

154 * @return Compiled message with inlined arg values.
155 */
156 private static String compile(String msg, Object[] args) {
157 int c = 0;
158 while(msg.contains("{}")) {
159 // Failsafe, shouldn't occur if logging is written correctly
160 if (c == args.length)
161 return msg;
162 // Replace arg in pattern
163 Object arg = args[c];
164 String argStr = arg == null ? "null" : arg.toString();
165 msg = msg.replaceFirst("\\{}", Matcher.quoteReplacement(argStr));
166 c++;
167 }
168 return msg;
169 }
170
171 static {
172 // Clear old log

Callers 5

traceMethod · 0.95
debugMethod · 0.95
infoMethod · 0.95
warnMethod · 0.95
errorMethod · 0.95

Calls 2

containsMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected