This is an automated email from the ASF dual-hosted git repository.

heneveld pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-server.git

commit ca3f54c51af0c51bc6e9f5141a16bd098b41cf48
Author: Alex Heneveld <[email protected]>
AuthorDate: Mon May 1 12:05:44 2023 +0100

    include logged message as part of other metadata for log
---
 .../brooklyn/core/workflow/WorkflowStepInstanceExecutionContext.java | 5 ++++-
 .../apache/brooklyn/core/workflow/steps/flow/LogWorkflowStep.java    | 4 ++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git 
a/core/src/main/java/org/apache/brooklyn/core/workflow/WorkflowStepInstanceExecutionContext.java
 
b/core/src/main/java/org/apache/brooklyn/core/workflow/WorkflowStepInstanceExecutionContext.java
index 8958904944..1342a1e66e 100644
--- 
a/core/src/main/java/org/apache/brooklyn/core/workflow/WorkflowStepInstanceExecutionContext.java
+++ 
b/core/src/main/java/org/apache/brooklyn/core/workflow/WorkflowStepInstanceExecutionContext.java
@@ -224,7 +224,10 @@ public class WorkflowStepInstanceExecutionContext {
 
     /** sets other metadata, e.g. for the UI */
     public void noteOtherMetadata(String key, Object value) {
-        log.debug(getWorkflowStepReference()+" note metadata '"+key+"': 
"+value);
+        noteOtherMetadata(key, value, true);
+    }
+    public void noteOtherMetadata(String key, Object value, boolean 
includeInLogs) {
+        if (includeInLogs) log.debug(getWorkflowStepReference()+" note 
metadata '"+key+"': "+value);
         otherMetadata.put(key, value);
     }
 
diff --git 
a/core/src/main/java/org/apache/brooklyn/core/workflow/steps/flow/LogWorkflowStep.java
 
b/core/src/main/java/org/apache/brooklyn/core/workflow/steps/flow/LogWorkflowStep.java
index 6cf91d3d3e..ca245f5acd 100644
--- 
a/core/src/main/java/org/apache/brooklyn/core/workflow/steps/flow/LogWorkflowStep.java
+++ 
b/core/src/main/java/org/apache/brooklyn/core/workflow/steps/flow/LogWorkflowStep.java
@@ -54,16 +54,20 @@ public class LogWorkflowStep extends WorkflowStepDefinition 
{
         if (!Strings.isBlank(category)) {
             log = LoggerFactory.getLogger(category);
         }
+        String messageLogged = message;
         if(!Strings.isBlank(level)) {
             Boolean levelExists = 
Arrays.stream(BrooklynLogging.LoggingLevel.values()).anyMatch((t) -> 
t.name().equals(level.toUpperCase()));
             if (levelExists) {
                 BrooklynLogging.log(log, 
BrooklynLogging.LoggingLevel.valueOf(level.toUpperCase()), message);
+                messageLogged = "["+level.toUpperCase()+"]  "+messageLogged;
             } else {
                 log.info("{}", message);
             }
         } else {
             log.info("{}", message);
         }
+        context.noteOtherMetadata("Message", messageLogged, false);  // show 
this so it is displayed on the step in the UI
+
         // TODO all workflow log messages should include step id as logging 
MDC, or message to start/end each workflow/task
         return context.getPreviousStepOutput();
     }

Reply via email to