mirror of
https://github.com/CodePhiliaX/Chat2DB.git
synced 2025-07-29 02:32:33 +08:00
mask log
This commit is contained in:
@ -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 + "]");
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user