-
Notifications
You must be signed in to change notification settings - Fork 441
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
Improve log mediator to support string templating #2230
Conversation
cd28c00
to
9b66249
Compare
modules/core/src/main/java/org/apache/synapse/util/InlineExpressionUtil.java
Outdated
Show resolved
Hide resolved
// Extract the expression inside ${...} | ||
String placeholder = matcher.group(1); | ||
SynapseExpression expression = new SynapseExpression(placeholder); | ||
String replacement = expression.stringValueOf(synCtx); |
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.
if the stringValueOf fails we get the value "unknown" should we print a warn log outside the while loop saying processed template might have an incorrect result since evaluation of some expressions failed.
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.
We cannot distinguish the unknown
at the mediator level. We may need to print the warn log at the evaluation.
082f1bf
to
c1e4644
Compare
@@ -288,6 +302,16 @@ public void setCategory(int category) { | |||
} | |||
} | |||
|
|||
public String getMessageTemplate() { | |||
|
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.
Why an additional new line?
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.
It's added by the wso2_code_style
for idea.
} | ||
|
||
public void setMessageTemplate(String messageTemplate) { | ||
|
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.
same as above
c1e4644
to
01b0af9
Compare
01b0af9
to
2463b2c
Compare
Purpose
In the current log mediator, the user needs to add a property and use XPATH concatenations to define a log message. With this improvement, the user can define a string template for the log message. In addition to the log message, the user can add additional properties to be logged.
To maintain backward compatibility when the user has set a
level
, the message will be printed in addition to the content printed according tolevel