Fix logger_formatter
about msg
by making templates linear before split
#6036
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I have encountered a somewhat strange behavior of
logger_formatter
aboutmsg
in templates. This pull request attempts to remedy it.The behavior is exemplified by the following application:
In summary,
msg
s occurring at conditional branching{metakey(), template(), template()}
in templates will not be formatted as intended.Looking into the implementation of
logger_formatter:format
, I have found that the implementation presumably assumes that given templates are of the form[Elem_1, …, Elem_{i - 1}, msg, Elem_{i + 1}, …, Elem_n]
or do not containmsg
. According to the definition oflogger_formatter:template()
, this assumption is not documented. Therefore, one of the following amendments seems to be needed:msg
must occur as a top level element of templates and at most once;logger_formatter:format
so thatmsg
s can occur under conditional branching but at most once for every “path”; orlogger_formatter:format
so thatmsg
s can occur everywhere in templates possibly more than once.The present pull request suggests an amendment based on the second approach. This is because using
msg
more than once in a “path” does not seem so usual and also its support will require a bit complicated implementation due to thechars_limit
option.I would appreciate it if you could give any comments or suggestions (especially since this is my first pull request to this repository).