MINOR: config: Created env variables for http and tcp clf formats

Since we already have variables for the other formats and the
change is trivial I thought it would be a nice addition for
completeness
This commit is contained in:
Nathan Wehrman 2024-08-20 09:11:34 -07:00 committed by Willy Tarreau
parent 599f043e74
commit 5c07d58e08
2 changed files with 12 additions and 0 deletions

View File

@ -927,6 +927,11 @@ file, or could be inherited by a program (See 3.7. Programs):
defined in section 8.2.3 "HTTP log format". It can be used to override the
default log format without having to copy the whole original definition.
* HAPROXY_HTTP_CLF_LOG_FMT: contains the value of the default HTTP CLF log
format as defined in section 8.2.3 "HTTP log format". It can be used to
override the default log format without having to copy the whole original
definition.
Example:
# Add the rule that gave the final verdict to the log
log-format "${HAPROXY_TCP_LOG_FMT} lr=last_rule_file:last_rule_line"
@ -937,6 +942,9 @@ file, or could be inherited by a program (See 3.7. Programs):
* HAPROXY_TCP_LOG_FMT: similar to HAPROXY_HTTP_LOG_FMT but for TCP log format
as defined in section 8.2.2 "TCP log format".
* HAPROXY_TCP_CLF_LOG_FMT: similar to HAPROXY_HTTP_CLF_LOG_FMT but for TCP CLF
log format as defined in section 8.2.2 "TCP log format".
* HAPROXY_MWORKER: In master-worker mode, this variable is set to 1.
* HAPROXY_CLI: configured listeners addresses of the stats socket for every

View File

@ -1189,8 +1189,10 @@ static int read_cfg(char *progname)
* unset them after the list_for_each_entry loop.
*/
setenv("HAPROXY_HTTP_LOG_FMT", default_http_log_format, 1);
setenv("HAPROXY_HTTP_CLF_LOG_FMT", clf_http_log_format, 1);
setenv("HAPROXY_HTTPS_LOG_FMT", default_https_log_format, 1);
setenv("HAPROXY_TCP_LOG_FMT", default_tcp_log_format, 1);
setenv("HAPROXY_TCP_CLF_LOG_FMT", clf_tcp_log_format, 1);
setenv("HAPROXY_BRANCH", PRODUCT_BRANCH, 1);
list_for_each_entry_safe(cfg, cfg_tmp, &cfg_cfgfiles, list) {
int ret;
@ -1220,8 +1222,10 @@ static int read_cfg(char *progname)
/* remove temporary environment variables. */
unsetenv("HAPROXY_BRANCH");
unsetenv("HAPROXY_HTTP_LOG_FMT");
unsetenv("HAPROXY_HTTP_CLF_LOG_FMT");
unsetenv("HAPROXY_HTTPS_LOG_FMT");
unsetenv("HAPROXY_TCP_LOG_FMT");
unsetenv("HAPROXY_TCP_CLF_LOG_FMT");
/* do not try to resolve arguments nor to spot inconsistencies when
* the configuration contains fatal errors.