You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by ma...@apache.org on 2022/02/28 18:22:06 UTC
[nifi] branch main updated: NIFI-9731: Updated to use a shorter, simpler output format for FlowFiles when creating bulletins
This is an automated email from the ASF dual-hosted git repository.
mattyb149 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/main by this push:
new 649e2d2 NIFI-9731: Updated to use a shorter, simpler output format for FlowFiles when creating bulletins
649e2d2 is described below
commit 649e2d25560318b7d8a0a6b7e5d2ab9c899e1af6
Author: Mark Payne <ma...@hotmail.com>
AuthorDate: Fri Feb 25 14:15:18 2022 -0500
NIFI-9731: Updated to use a shorter, simpler output format for FlowFiles when creating bulletins
NIFI-9731: Only simplify flowfile arg in bulletin after extracting the flowfile uuid
Signed-off-by: Matthew Burgess <ma...@apache.org>
This closes #5808
---
.../logging/repository/StandardLogRepository.java | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/logging/repository/StandardLogRepository.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/logging/repository/StandardLogRepository.java
index d2859f6..a251ca9 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/logging/repository/StandardLogRepository.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/logging/repository/StandardLogRepository.java
@@ -68,8 +68,8 @@ public class StandardLogRepository implements LogRepository {
@Override
public void addLogMessage(final LogLevel level, final String format, final Object[] params) {
- replaceThrowablesWithMessage(params);
final Optional<String> flowFileUuid = getFirstFlowFileUuidFromObjects(params);
+ simplifyArgs(params);
final String formattedMessage = MessageFormatter.arrayFormat(format, params).getMessage();
final LogMessage logMessage = new LogMessage.Builder(System.currentTimeMillis(), level)
.message(formattedMessage)
@@ -80,8 +80,8 @@ public class StandardLogRepository implements LogRepository {
@Override
public void addLogMessage(final LogLevel level, final String format, final Object[] params, final Throwable t) {
- replaceThrowablesWithMessage(params);
final Optional<String> flowFileUuid = getFirstFlowFileUuidFromObjects(params);
+ simplifyArgs(params);
final String formattedMessage = MessageFormatter.arrayFormat(format, params, t).getMessage();
final LogMessage logMessage = new LogMessage.Builder(System.currentTimeMillis(), level)
.message(formattedMessage)
@@ -105,14 +105,23 @@ public class StandardLogRepository implements LogRepository {
return Optional.ofNullable(flowFileFound).map(ff -> ff.getAttribute(CoreAttributes.UUID.key()));
}
- private void replaceThrowablesWithMessage(final Object[] params) {
+ private void simplifyArgs(final Object[] params) {
for (int i = 0; i < params.length; i++) {
- if (params[i] instanceof Throwable) {
- params[i] = ((Throwable) params[i]).getLocalizedMessage();
- }
+ params[i] = simplifyArg(params[i]);
}
}
+ private Object simplifyArg(final Object param) {
+ if (param instanceof Throwable) {
+ return ((Throwable) param).getLocalizedMessage();
+ } else if (param instanceof FlowFile) {
+ final FlowFile flowFile = (FlowFile) param;
+ return "FlowFile[filename=" + flowFile.getAttribute(CoreAttributes.FILENAME.key()) + "]";
+ }
+
+ return param;
+ }
+
@Override
public void setObservationLevel(String observerIdentifier, LogLevel level) {
writeLock.lock();