-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add a warning in case of incorrect syntax of highlighting style. #1637
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
Conversation
@ppkarwasz I wonder If there's a way to check on a specific logged message in one of the unit tests? |
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.
Better message IMO:
Syntax error, missing '=': Expected "{KEY1=VALUE, KEY2=VALUE, ...}"
Noted, but I have a question regarding the following code block:
To avoid false positive warning messages, aren't we need to replace also the commas with Strings.empty()? So I'd suggest to tweak the match pattern to looks like the following:
|
@aawad6, A while back I added a @Test
@UsingStatusListener
public void testSomething(final ListStatusListener listener) {
...
assertThat(listener.findStatusData(Level.WARN)).hasSize(1);
...
} Regarding the "disableAnsi" and "noConsoleNoAnsi" keys, we could probably deal with them better. E.g. instead of removing them through a regex, we can add them to the |
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.
Apart from the comment below, it looks good to me.
log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/HighlightConverter.java
Show resolved
Hide resolved
Thanks for the improvement @aawad6, much appreciated! 🙇 Merging it... |
Add a warning in case of incorrect syntax of highlighting style (without
=
).This PR is related to #issue1545, it meant to ensure that the user is providing a correct syntax for highlighting style.
e.g.
%highlight{%5level}{LOGBACK}
should be%highlight{%5level}{STYLE=LOGBACK}
. For more information see the documentation here.