Skip to content

Commit

Permalink
perf($WebLog): trim printed JSON string
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnymillergh committed Mar 9, 2020
1 parent 2f1f63a commit 48e7984
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 12 deletions.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,11 @@ public Object aroundHandleRequest(ProceedingJoinPoint proceedingJoinPoint) throw
Object result = proceedingJoinPoint.proceed();
long elapsedTime = System.currentTimeMillis() - startTime;
try {
log.info("Response :{}{}", LINE_SEPARATOR,
JSONUtil.formatJsonStr(mapper.writeValueAsString(result)));
var formattedStringifiedJson = JSONUtil.formatJsonStr(mapper.writeValueAsString(result));
if (formattedStringifiedJson.length() > 500) {
formattedStringifiedJson = formattedStringifiedJson.substring(0, 499).concat("…");
}
log.info("Response :{}{}", LINE_SEPARATOR, formattedStringifiedJson);
} catch (JsonProcessingException e) {
log.info("Response (non-JSON): {}", result);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,11 @@ public Object aroundHandleRequest(ProceedingJoinPoint proceedingJoinPoint) throw
Object result = proceedingJoinPoint.proceed();
long elapsedTime = System.currentTimeMillis() - startTime;
try {
log.info("Response :{}{}", LINE_SEPARATOR,
JSONUtil.formatJsonStr(mapper.writeValueAsString(result)));
var formattedStringifiedJson = JSONUtil.formatJsonStr(mapper.writeValueAsString(result));
if (formattedStringifiedJson.length() > 500) {
formattedStringifiedJson = formattedStringifiedJson.substring(0, 499).concat("…");
}
log.info("Response :{}{}", LINE_SEPARATOR, formattedStringifiedJson);
} catch (JsonProcessingException e) {
log.info("Response (non-JSON): {}", result);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,11 @@ public Object aroundHandleRequest(ProceedingJoinPoint proceedingJoinPoint) throw
Object result = proceedingJoinPoint.proceed();
long elapsedTime = System.currentTimeMillis() - startTime;
try {
log.info("Response :{}{}", LINE_SEPARATOR,
JSONUtil.formatJsonStr(mapper.writeValueAsString(result)));
var formattedStringifiedJson = JSONUtil.formatJsonStr(mapper.writeValueAsString(result));
if (formattedStringifiedJson.length() > 500) {
formattedStringifiedJson = formattedStringifiedJson.substring(0, 499).concat("…");
}
log.info("Response :{}{}", LINE_SEPARATOR, formattedStringifiedJson);
} catch (JsonProcessingException e) {
log.info("Response (non-JSON): {}", result);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,11 @@ public Object aroundHandleRequest(ProceedingJoinPoint proceedingJoinPoint) throw
Object result = proceedingJoinPoint.proceed();
long elapsedTime = System.currentTimeMillis() - startTime;
try {
log.info("Response :{}{}", LINE_SEPARATOR,
JSONUtil.formatJsonStr(mapper.writeValueAsString(result)));
var formattedStringifiedJson = JSONUtil.formatJsonStr(mapper.writeValueAsString(result));
if (formattedStringifiedJson.length() > 500) {
formattedStringifiedJson = formattedStringifiedJson.substring(0, 499).concat("…");
}
log.info("Response :{}{}", LINE_SEPARATOR, formattedStringifiedJson);
} catch (JsonProcessingException e) {
log.info("Response (non-JSON): {}", result);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,11 @@ public Object aroundHandleRequest(ProceedingJoinPoint proceedingJoinPoint) throw
Object result = proceedingJoinPoint.proceed();
long elapsedTime = System.currentTimeMillis() - startTime;
try {
log.info("Response :{}{}", LINE_SEPARATOR,
JSONUtil.formatJsonStr(mapper.writeValueAsString(result)));
var formattedStringifiedJson = JSONUtil.formatJsonStr(mapper.writeValueAsString(result));
if (formattedStringifiedJson.length() > 500) {
formattedStringifiedJson = formattedStringifiedJson.substring(0, 499).concat("…");
}
log.info("Response :{}{}", LINE_SEPARATOR, formattedStringifiedJson);
} catch (JsonProcessingException e) {
log.info("Response (non-JSON): {}", result);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,11 @@ public Object aroundHandleRequest(ProceedingJoinPoint proceedingJoinPoint) throw
Object result = proceedingJoinPoint.proceed();
long elapsedTime = System.currentTimeMillis() - startTime;
try {
log.info("Response :{}{}", LINE_SEPARATOR,
JSONUtil.formatJsonStr(mapper.writeValueAsString(result)));
var formattedStringifiedJson = JSONUtil.formatJsonStr(mapper.writeValueAsString(result));
if (formattedStringifiedJson.length() > 500) {
formattedStringifiedJson = formattedStringifiedJson.substring(0, 499).concat("…");
}
log.info("Response :{}{}", LINE_SEPARATOR, formattedStringifiedJson);
} catch (JsonProcessingException e) {
log.info("Response (non-JSON): {}", result);
}
Expand Down

0 comments on commit 48e7984

Please sign in to comment.