Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize the log printing when multiple error occur #12732

Merged
merged 2 commits into from
Jun 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading