shichaoyuan commented on issue #13591:
URL: https://github.com/apache/skywalking/issues/13591#issuecomment-3579277026
> We don't want to use complex regex to be honest. Why we need to put agent
logs so complex? It should be just a simple version implementation, as agent
plugin is the only one using it. This is not an app logger.
I fully agree with your point. Regular expressions are unnecessary here,
simple string replacement would suffice for implementation.
```java
protected String replaceParam(String message, Object... parameters) {
if (message == null) {
return message;
}
int startSize = 0;
int parametersIndex = 0;
int index;
StringBuilder sb = new StringBuilder(message);
while ((index = sb.indexOf("{}", startSize)) != -1) {
if (parametersIndex >= parameters.length) {
break;
}
String tmp = String.valueOf(parameters[parametersIndex++]);
sb.replace(index, index+2, tmp);
startSize = index + tmp.length();
}
return sb.toString();
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]