This commit is contained in:
robin
2023-08-13 17:09:32 +08:00
parent 79ffd2c1f2
commit b94ce9fd88
2 changed files with 4 additions and 4 deletions

View File

@ -54,10 +54,10 @@ public class EasyLogSink implements Sink {
webLog.setStartTime(LocalDateTime.ofInstant(correlation.getStart(), ZoneId.systemDefault()));
webLog.setEndTime(LocalDateTime.ofInstant(correlation.getEnd(), ZoneId.systemDefault()));
try {
webLog.setRequest(LogUtils.cutLog(new String(request.getBody(), StandardCharsets.UTF_8)));
webLog.setRequest(LogUtils.maskString(LogUtils.cutLog(new String(request.getBody(), StandardCharsets.UTF_8))));
if (ContentTypeUtils.isContentTypeJSON(response.getContentType()) || ContentTypeUtils.isContentTypeHTML(
response.getContentType())) {
webLog.setResponse(LogUtils.cutLog(new String(response.getBody(), StandardCharsets.UTF_8)));
webLog.setResponse(LogUtils.maskString(LogUtils.cutLog(new String(response.getBody(), StandardCharsets.UTF_8))));
} else {
webLog.setResponse(response.getContentType() + ":[" + response.getBody().length + "]");
}

View File

@ -43,7 +43,7 @@ public class LogUtils {
* @param input
* @return
*/
private static String maskString(String input) {
public static String maskString(String input) {
if (StringUtils.isBlank(input)) {
return input;
}
@ -78,7 +78,7 @@ public class LogUtils {
if (Objects.isNull(log)) {
return null;
}
return EasyStringUtils.limitString(maskString(removeCrlf(log.toString())), MAX_LOG_LENGTH);
return EasyStringUtils.limitString(removeCrlf(log.toString()), MAX_LOG_LENGTH);
}
/**