Skip to content

Commit

Permalink
DAT-15208 :: Changeset object added back to "Update command completed…
Browse files Browse the repository at this point in the history
… successfully" JSON (#4581)

Update logDeploymentOutcomeMdc to add mdc values before logging update command execution result.
  • Loading branch information
MalloD12 committed Aug 1, 2023
1 parent 5cfe92d commit b59bdcb
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,16 @@ public void cleanUp(CommandResultsBuilder resultsBuilder) {
private void logDeploymentOutcomeMdc(ChangeExecListener defaultListener, boolean success) {
String successLog = "Update command completed successfully.";
String failureLog = "Update command encountered an exception.";
try (MdcObject deploymentOutcomeMdc = Scope.getCurrentScope().addMdcValue(MdcKey.DEPLOYMENT_OUTCOME, success ? MdcValue.COMMAND_SUCCESSFUL : MdcValue.COMMAND_FAILED)) {
Scope.getCurrentScope().getLog(getClass()).info(success ? successLog : failureLog);
}

if (defaultListener instanceof DefaultChangeExecListener) {
List<ChangeSet> deployedChangeSets = ((DefaultChangeExecListener)defaultListener).getDeployedChangeSets();
int deployedChangeSetCount = deployedChangeSets.size();
ChangesetsUpdated changesetsUpdated = new ChangesetsUpdated(deployedChangeSets);
Scope.getCurrentScope().addMdcValue(MdcKey.DEPLOYMENT_OUTCOME_COUNT, String.valueOf(deployedChangeSetCount));
Scope.getCurrentScope().addMdcValue(MdcKey.CHANGESETS_UPDATED, changesetsUpdated);
}
try (MdcObject deploymentOutcomeMdc = Scope.getCurrentScope().addMdcValue(MdcKey.DEPLOYMENT_OUTCOME, success ? MdcValue.COMMAND_SUCCESSFUL : MdcValue.COMMAND_FAILED)) {
Scope.getCurrentScope().getLog(getClass()).info(success ? successLog : failureLog);
}
}

@Beta
Expand Down

0 comments on commit b59bdcb

Please sign in to comment.