]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: sample: add the "when" converter to condition some expressions
authorWilly Tarreau <w@1wt.eu>
Tue, 22 Oct 2024 17:43:18 +0000 (19:43 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 22 Oct 2024 18:13:00 +0000 (20:13 +0200)
commitb74fb1325e60a2573f1ed8a460129bc6c0c9e53f
treefbfec293f15605102e98d1d67c75d8af1ca2afb5
parent19e4ec43b91113fc89e1695665e9afa7a4dd4bbd
MINOR: sample: add the "when" converter to condition some expressions

Sometimes it would be desirable to include some debugging output only
under certain conditions, but the end of the transfer is too late to
apply some rules.

Here we take the approach of making a converter ("when") that takes a
condition among an arbitrary list, and decides whether or not to let
the input sample pass through or not based on the condition. This
allows for example to log debugging information only when an error
was encountered during the processing (sort of an extension of
dontlog-normal). The conditions are quite limited (stopping, error,
normal, toapplet, forwarded, processed) and can be negated. The
converter can also be chained to use more complex conditions.

A suggested example will be:

    # log "dbg={-}" when fine, or "dbg={... debug info ...}" on error:
    log-format "$HAPROXY_HTTP_LOG_FMT dbg={%[bs.debug_str,when(!normal)]}"
doc/configuration.txt
src/sample.c