]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: log: simplify quotes handling in sess_build_logline()
authorAurelien DARRAGON <adarragon@haproxy.com>
Wed, 10 Jan 2024 18:14:25 +0000 (19:14 +0100)
committerAurelien DARRAGON <adarragon@haproxy.com>
Tue, 20 Feb 2024 14:49:55 +0000 (15:49 +0100)
commita2fc40bc2808bd508ead528cce067b4b3437e518
treecc9720d4beb0a3419a8f5c0287bbbcd5228a7e87
parentc6a7138420807db7cf0450208a3102584d424103
MINOR: log: simplify quotes handling in sess_build_logline()

quotes building for some log formats is directly performed under each
switch case statement so it would become painful to add other conditions
to prevent the quotes from being generated when it's not supported by the
the data encoding format for instance (ie: JSON).

Let's centralize and simplify quotes handling by adding LOGQUOTE_START()
and LOGQUOTE_END() helper macros. If a quotation is started and not
explicitly ended, it will be automatically ended at the end of the current
logformat node:

LOGQUOTE_START() sets 'quote' variable to 1, this way LOGQUOTE_END() only
prints the ending quote when needed. LOGQUOTE_END() is systematically
called after each node switch-case (after each value). LOGQUOTE_START()
does nothing if LOG_OPT_QUOTE isn't set, so does LOGQUOTE_END().

Some rare cases such as %hsl (list of captured headers) required special
handling: in this case multiple quoted texts are generated for the same
field value so explicit LOGQUOTE_START() + LOGQUOTE_END() combination was
needed.
src/log.c