Skip to content
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

Closed
wants to merge 3 commits into from

Conversation

kotarot
Copy link
Member

@kotarot kotarot commented Nov 1, 2018

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:

  • Have you ensured that the full suite of tests is executed via mvn -Pcontrib-check clean install at the root nifi folder?
  • Have you written or updated unit tests to verify your changes?
  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
  • If applicable, have you updated the LICENSE file, including the main LICENSE file under nifi-assembly?
  • If applicable, have you updated the NOTICE file, including the main NOTICE file found under nifi-assembly?
  • If adding new Properties, have you added .displayName in addition to .name (programmatic access) for each of the new properties?

For documentation related changes:

  • Have you ensured that format looks appropriate for the output in which it is rendered?

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.

@@ -57,7 +57,7 @@ MockComponentLog getMockComponentLog() {
public void before() throws InitializationException {
testableLogMessage = new TestableLogMessage();
runner = TestRunners.newTestRunner(testableLogMessage);

runner.setValidateExpressionUsage(false);
Copy link
Contributor

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!

Copy link
Member

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..

Copy link
Contributor

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?

Copy link
Member

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:
image

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?

Copy link
Member Author

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?

Copy link
Contributor

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 ;)

@kotarot
Copy link
Member Author

kotarot commented Nov 6, 2018

@pvillard31 @ijokarumawak Updated the property to support EL. Would you please check it?

@ijokarumawak
Copy link
Member

LGTM, +1. Merging. Thanks @kotarot !

@asfgit asfgit closed this in 0c9120a Nov 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants