Skip to content

Commit

Permalink
Optimize the log printing when multiple error occur (#12732)
Browse files Browse the repository at this point in the history
  • Loading branch information
HTHou authored Jun 13, 2024
1 parent 0dbb389 commit 7b993f4
Showing 1 changed file with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,18 +146,20 @@ public static TSStatus getStatus(TSStatusCode tsStatusCode) {
public static TSStatus getStatus(List<TSStatus> statusList) {
TSStatus status = new TSStatus(TSStatusCode.MULTIPLE_ERROR.getStatusCode());
status.setSubStatus(statusList);
StringBuilder errMsg = new StringBuilder().append("Multiple error occur, messages: ");
Set<String> msgSet = new HashSet<>();
for (TSStatus subStatus : statusList) {
if (subStatus.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()
&& subStatus.getCode() != TSStatusCode.REDIRECTION_RECOMMEND.getStatusCode()) {
if (!msgSet.contains(status.getMessage())) {
errMsg.append(status.getMessage()).append("; ");
msgSet.add(status.getMessage());
if (LOGGER.isDebugEnabled()) {
StringBuilder errMsg = new StringBuilder().append("Multiple error occur, messages: ");
Set<TSStatus> msgSet = new HashSet<>();
for (TSStatus subStatus : statusList) {
if (subStatus.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()
&& subStatus.getCode() != TSStatusCode.REDIRECTION_RECOMMEND.getStatusCode()) {
if (!msgSet.contains(status)) {
errMsg.append(status).append("; ");
msgSet.add(status);
}
}
}
LOGGER.debug(errMsg.toString(), new Exception(errMsg.toString()));
}
LOGGER.warn(errMsg.toString());
return status;
}

Expand Down

0 comments on commit 7b993f4

Please sign in to comment.