Consolidate stack trace rendering in Pattern Layout#2691
Conversation
|
Changes are based on the feedback in #1137. Please let me know where to improve, thanks |
|
Also I want to add more tests to cover the changes, but my Intellij IDEA shows below when I tried to run Also my Could you let me know how to fix it? |
vy
left a comment
There was a problem hiding this comment.
Great work @alan0428a! I have requested some changes.
See BUILDING.adoc explaining how a typical development cycle works, how to run tests, etc.
|
@alan0428a, not to mention I am expecting to see several new tests. In particular, for |
|
Also add tests to cover the changes, please review when you have time. |
vy
left a comment
There was a problem hiding this comment.
@alan0428a, thank you so much your great effort! 💯 It has been much appreciated! 🙇 I request more changes, but I think we are heading in the right direction. Please keep these contributions coming! 🚀
|
@alan0428a, could you also create a |
|
Note about the test failures: unfortunately we have about a dozen of flaky tests in our project (see the Develocity statistics for a list). The failures in the Log4j Tag Library on the other hand seem connected to this PR and need to be investigated. |
|
Just checked it's because before the PR, The implementation in I am thinking the flow will be like(Just like the old way, but do not use Though the behavior is different from WDYT? |
|
Well shucks, while you were in there it would be nice to resolve LOG4J2-2170 and add in the module information. |
@rgoers, that ticket is implicitly resolved too. I added tests for that and updated the changelog entry. |
ppkarwasz
left a comment
There was a problem hiding this comment.
@alan0428a and @vy, great job! 💯
This looks good to me, except the leading space that is added to each stack trace: Throwable.printStackTrace() does have a trailing new line, but does not have a leading space.
I know that the leading space was already there before, but it is quite unexpected. If a user asks for a %m%ex pattern, he should get just that: the message and the exception without anything inbetween.
I would remove the leading space and add it to the logic that automatically appends %xEx to a pattern:
- if a pattern does not contain an exception specifier and ends in
%nor a whitespace character, then%xExis appended, - if a pattern does not contain an exception specifier and does not end in either
%nnor whitespace, then%xExis appended.
WDYT?
Note
I find the current algorithm that determines if a pattern contains an exception specifier extremely fragile.
The altorithm fails to detect any nested occurrence of %ex, e.g. %hightlight{%ex} or %notEmpty{ %ex}.
@ppkarwasz, I implemented this, and it caused 99 test failures in |
Co-authored-by: Piotr P. Karwasz <piotr.github@karwasz.org> Co-authored-by: Volkan Yazıcı <volkan@yazi.ci>
This PR
%ex,%rEx, and%xExconverters)%exto implement%rExand%xEx. This effectively fixes:ThrowableProxyand all its usages