字符串格式化输出修复
parent
3a2234cbcc
commit
0dde57349d
|
@ -3072,20 +3072,25 @@ public class Util extends weaver.general.Util {
|
||||||
Matcher matcher = compile.matcher(logStr);
|
Matcher matcher = compile.matcher(logStr);
|
||||||
int n = 0;
|
int n = 0;
|
||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
|
if (n + 1 > args.length) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
logStr = logStr.replaceFirst(pattern, "{" + n++ + "}");
|
logStr = logStr.replaceFirst(pattern, "{" + n++ + "}");
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
Object arg = args[args.length - 1];
|
Object arg = args[args.length - 1];
|
||||||
if (arg instanceof Throwable) {
|
if (arg instanceof Throwable) {
|
||||||
for (int i = 0; i < args.length - 1; i++) {
|
for (int i = 0; i < args.length - 1; i++) {
|
||||||
pattern = "\\{" + i + "}";
|
pattern = "\\{" + i + "}";
|
||||||
logStr = logStr.replaceFirst(pattern, String.valueOf(args[i].toString()));
|
logStr = logStr.replaceFirst(pattern, String.valueOf(args[i]));
|
||||||
}
|
}
|
||||||
return logStr + "\n" + getErrString((Throwable) arg);
|
return logStr + "\n" + getErrString((Throwable) arg);
|
||||||
}
|
}
|
||||||
int i = 0;
|
} catch (Exception ignore) {
|
||||||
for (Object o : args) {
|
}
|
||||||
pattern = "\\{" + i++ + "}";
|
for (int i = 0; i < args.length; i++) {
|
||||||
logStr = logStr.replaceFirst(pattern, String.valueOf(o));
|
pattern = "\\{" + i + "}";
|
||||||
|
logStr = logStr.replaceFirst(pattern, String.valueOf(args[i]));
|
||||||
}
|
}
|
||||||
return logStr;
|
return logStr;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -1020,8 +1020,12 @@ public class HttpUtils {
|
||||||
*/
|
*/
|
||||||
private HttpPost uploadFileByInputStream(String url, List<HttpMultipartFile> multipartFileList,
|
private HttpPost uploadFileByInputStream(String url, List<HttpMultipartFile> multipartFileList,
|
||||||
Map<String, Object> params, Map<String, String> headers) {
|
Map<String, Object> params, Map<String, String> headers) {
|
||||||
log.info(Util.logStr("start request : url is [{}]" +
|
log.info(Util.logStr("start request : url is [{}],other param [\n{}\n],heard [\n{}\n]", url, JSONObject.toJSONString(params,
|
||||||
"", url));
|
SerializerFeature.PrettyFormat,
|
||||||
|
SerializerFeature.WriteDateUseDateFormat),
|
||||||
|
JSONObject.toJSONString(headers,
|
||||||
|
SerializerFeature.PrettyFormat,
|
||||||
|
SerializerFeature.WriteDateUseDateFormat)));
|
||||||
HttpUtilParamInfo httpUtilParamInfo = new HttpUtilParamInfo();
|
HttpUtilParamInfo httpUtilParamInfo = new HttpUtilParamInfo();
|
||||||
httpUtilParamInfo.setParams(params);
|
httpUtilParamInfo.setParams(params);
|
||||||
httpUtilParamInfo.setUrl(url);
|
httpUtilParamInfo.setUrl(url);
|
||||||
|
@ -1069,8 +1073,12 @@ public class HttpUtils {
|
||||||
*/
|
*/
|
||||||
private HttpPut uploadFileByInputStreamPut(String url, List<HttpMultipartFile> multipartFileList,
|
private HttpPut uploadFileByInputStreamPut(String url, List<HttpMultipartFile> multipartFileList,
|
||||||
Map<String, Object> params, Map<String, String> headers) {
|
Map<String, Object> params, Map<String, String> headers) {
|
||||||
log.info(Util.logStr("start request : url is [{}]" +
|
log.info(Util.logStr("start request : url is [{}],other param [\n{}\n],heard [\n{}\n]", url, JSONObject.toJSONString(params,
|
||||||
"", url));
|
SerializerFeature.PrettyFormat,
|
||||||
|
SerializerFeature.WriteDateUseDateFormat),
|
||||||
|
JSONObject.toJSONString(headers,
|
||||||
|
SerializerFeature.PrettyFormat,
|
||||||
|
SerializerFeature.WriteDateUseDateFormat)));
|
||||||
HttpUtilParamInfo httpUtilParamInfo = new HttpUtilParamInfo();
|
HttpUtilParamInfo httpUtilParamInfo = new HttpUtilParamInfo();
|
||||||
httpUtilParamInfo.setParams(params);
|
httpUtilParamInfo.setParams(params);
|
||||||
httpUtilParamInfo.setUrl(url);
|
httpUtilParamInfo.setUrl(url);
|
||||||
|
|
|
@ -111,7 +111,7 @@ public class TestOrganization extends BaseTest {
|
||||||
log.info("哈哈哈好的方式");
|
log.info("哈哈哈好的方式");
|
||||||
String testStr = "weaver.xuanran.wang.schroeder.cus_field_value.PushSealTaskSealValue?sealSnField=sealSn&sealNumField=sealNum&sealSnCusSql=`select\n" +
|
String testStr = "weaver.xuanran.wang.schroeder.cus_field_value.PushSealTaskSealValue?sealSnField=sealSn&sealNumField=sealNum&sealSnCusSql=`select\n" +
|
||||||
" ? from jkfdjsfk where id\n" +
|
" ? from jkfdjsfk where id\n" +
|
||||||
"=1`&sealNumCusSql=`select case ? when 0 then htzyzcs when 1 then gzcs else frzcs end from formtable_main_22_dt1 where id = {?dt.id}`&cus=`select * from table id = ? and test = ?`";
|
" =1`&sealNumCusSql=`select case ? when 0 then htzyzcs when 1 then gzcs else frzcs end from formtable_main_22_dt1 where id = {?dt.id}`&hah=liuliu&cus=`select? * fr$%&#@!)(<>?/\\{}「」【【】[]~、asfom table where id = '' and teset = #{name}`&niua=卧槽";
|
||||||
Map<String, String> stringStringMap = Util.parseCusInterfacePathParam(testStr);
|
Map<String, String> stringStringMap = Util.parseCusInterfacePathParam(testStr);
|
||||||
System.out.println(stringStringMap);
|
System.out.println(stringStringMap);
|
||||||
System.out.println(JSON.toJSONString(stringStringMap));
|
System.out.println(JSON.toJSONString(stringStringMap));
|
||||||
|
@ -140,7 +140,11 @@ public class TestOrganization extends BaseTest {
|
||||||
if (paramValue != null && paramValue.startsWith("`") && paramValue.endsWith("`")) {
|
if (paramValue != null && paramValue.startsWith("`") && paramValue.endsWith("`")) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLogStr() {
|
||||||
|
System.out.println(Util.logStr("ajsdf {} jasjdf {}", "asf", "asdfeag"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue