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
NIFI-5777: Update the tag and the property of LogMessage #3122
Conversation
@@ -57,7 +57,7 @@ MockComponentLog getMockComponentLog() { | |||
public void before() throws InitializationException { | |||
testableLogMessage = new TestableLogMessage(); | |||
runner = TestRunners.newTestRunner(testableLogMessage); | |||
|
|||
runner.setValidateExpressionUsage(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree with this change: disabling the expression usage validation should be avoided as much as possible and, if I recall correctly, is only necessary in very specific edge cases. Instead of disabling the validation, I'd fix the original issue by removing .evaluateAttributeExpressions(flowFile)
on L129 in LogMessage since it does not make sense. Once it's fixed, I'm a +1 and can merge to master. Feel free to squash your commits. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I think changing logLevel based on expression makes sense. For example, if you want to debug for a particular type of FlowFiles, you'd use EL to write WARN level log for specific attribute value and use TRACE/DEBUG for others to minimize the noise. I don't think specifying log level by text is a critical issue..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case I'm not sure to understand the intent of this PR. Initially I thought it was about removing .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
on LOG_LEVEL
since the property only accepts a list of allowed values. If we do that, then we should remove the .evaluateAttributeExpressions(flowFile)
, no?
On the other hand, if we do want to allow EL on this property, then the property and code should be changed to allow free text value that is validated against the list of allowed values only if EL is not used. And then if EL is used, there should be a default behavior in case the value, after EL evaluation, is not an allowed value.
Am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the confusion. I was just looking at the source code. When I run the processor, I realized that the processor doesn't allow EL. The logLevel is shown as a free text input, and I can input EL, but validation failed because of the configured allowable values.
I still think changing log level by EL would be nice:
My suggestion is, changing:
.description("The Log Level to use when logging the message")
.allowableValues(MessageLogLevel.values())
to
.description("The Log Level to use when logging the message: " + Arrays.toString(MessageLogLevel.values()))
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
How do you guys think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pvillard31 @ijokarumawak Thank you for your reviews.
At first, the purpose of my PR was, to enable to pick up a Log Level from the pull-down list (as we can do it on the LogAttribute processor), so that I would like to make it easier for users (including NiFi beginners) to use this processor.
As @ijokarumawak has suggested, should I fix it to be EL acceptable for flexible logging usages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah sounds good to me to have EL support ;)
@pvillard31 @ijokarumawak Updated the property to support EL. Would you please check it? |
LGTM, +1. Merging. Thanks @kotarot ! |
Thank you for submitting a contribution to Apache NiFi.
In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:
For all changes:
Is there a JIRA ticket associated with this PR? Is it referenced
in the commit message?
Does your PR title start with NIFI-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
Has your PR been rebased against the latest commit within the target branch (typically master)?
Is your initial contribution a single, squashed commit?
For code changes:
For documentation related changes:
Note:
Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.