fix: no dot when converting %f to timestamp layout
Description of the issue
In a timestamp format, %f (fraction of seconds) represents the digits, not including the decimal mark (point or comma). So when converting a format to a layout, %f should be replaced with 000.
For example, the format "%H:%M:%S.%f" should be converted to the layout "15:04:05.000". Currently, the code incorrectly converts that format to "15:04:05..000" (note the two dots).
The capturing group for %f in TimeFormatRexMap looks wrong as no other mapping uses a capturing group.
Description of changes
%f in a format is mapped to "000", instead of ".000", in a layout.
License
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Tests
None.
Requirements
Before commit the code, please do the following steps.
- Run
make fmtandmake fmt-sh - Run
make linter
Hi @manger , Thanks for the great contribution on this problem and it would be better to show what have you done by testing with CWA: before and after so we would have confidence in delivering it and ensure there is no regression. Will give a more detail review later on.
This PR was marked stale due to lack of activity.
@manger can you give a reproducible example for us to validate against?
@manger can you give a reproducible example for us to validate against?
The default timestamp format for Log4J2 %d produces timestamps such as
2006-01-02 22:04:05,000 or 2012-11-02 14:34:02,123
with fraction-of-seconds to millisecond precision, and a decimal comma.
That is an example that doesn't work without a fix.
This PR was marked stale due to lack of activity.