]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: sample: allow custom date format in error-log-format
authorValentine Krasnobaeva <vkrasnobaeva@haproxy.com>
Tue, 4 Mar 2025 15:35:05 +0000 (16:35 +0100)
committerWilliam Lallemand <wlallemand@haproxy.com>
Tue, 4 Mar 2025 17:57:29 +0000 (18:57 +0100)
commitb46b81949fc9d100eb1c023a7c7b5036f13226bc
tree4e67cdd1d974b0ac4fd963e1e6953e18e27f9abc
parent335ef3264b8c5ebb5bd8f0e327da90d7107e853b
MINOR: sample: allow custom date format in error-log-format

Sample fetches %[accept_date] and %[request_date] with converters can be used
in error-log-format string. But in the most error cases they fetches nothing,
as error logs are produced on SSL handshake issues or when invalid PROXY
protocol header is used. Stream object is never allocated in such cases and
smp_fetch_accept_date() just simply returns 0.

There is a need to have a custom date format (ISO8601) also in the error logs,
along with normal logs. When sess_build_logline_orig() builds log line it
always copies the accept date to strm_logs structure. When stream is absent,
accept date is copied from the session object.

So, if the steam object wasn't allocated, let's use the session date info in
smp_fetch_accept_date(). This allows then, in sample_process(), to apply to the
fetched date different converters and formats.

This fixes the issue #2884.
src/tcp_sample.c