From 8d850e2ba4f22f3da1d0a0212884f503e7a7ebf9 Mon Sep 17 00:00:00 2001 From: David Waltermire Date: Sat, 19 Oct 2024 11:01:34 -0400 Subject: [PATCH] Add the constraint id to the console message if the finding has an associated id. (#181) --- .../cli/util/LoggingValidationHandler.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/metaschema-cli/src/main/java/gov/nist/secauto/metaschema/cli/util/LoggingValidationHandler.java b/metaschema-cli/src/main/java/gov/nist/secauto/metaschema/cli/util/LoggingValidationHandler.java index 27167b6fa..104a072e5 100644 --- a/metaschema-cli/src/main/java/gov/nist/secauto/metaschema/cli/util/LoggingValidationHandler.java +++ b/metaschema-cli/src/main/java/gov/nist/secauto/metaschema/cli/util/LoggingValidationHandler.java @@ -53,8 +53,7 @@ public static LoggingValidationHandler instance() { * Get a singleton instance of the logging validation handler. * * @param logExceptions - * {@code true} if this instance will log exceptions or {@code false} - * otherwise + * {@code true} if this instance will log exceptions or {@code false} otherwise * @return the instance */ @SuppressFBWarnings(value = "SING_SINGLETON_GETTER_NOT_SYNCHRONIZED", @@ -148,8 +147,15 @@ private void handleXmlValidationFinding(XmlValidationFinding finding) { private void handleConstraintValidationFinding(@NonNull ConstraintValidationFinding finding) { Ansi ansi = generatePreamble(finding.getSeverity()); + ansi.format("[%s]", finding.getTarget().getMetapath()); + + String id = finding.getIdentifier(); + if (id != null) { + ansi.format(" %s: ", id); + } + getLogger(finding).log( - ansi.format("[%s] %s", finding.getTarget().getMetapath(), finding.getMessage())); + ansi.format(" %s", finding.getTarget().getMetapath(), finding.getMessage())); } @NonNull