From: Willy Tarreau Date: Thu, 8 Oct 2026 16:42:16 +0000 (+0200) Subject: MINOR: log: add proxy_logformat_origin() to detect a proxy's log-format type X-Git-Url: https://git.kaiwu.me/?a=commitdiff_plain;h=7aa4687330527da23a5f7f0bb4d09b115f1a9bfa;p=haproxy.git MINOR: log: add proxy_logformat_origin() to detect a proxy's log-format type This new function will check the proxy's logformat.str and return return an option name (e.g. "option httplog") or a directive ("log-format") that will permit error messages to report where a log-format had been set. --- diff --git a/include/haproxy/log.h b/include/haproxy/log.h index 79330e0f0..0dbbae3eb 100644 --- a/include/haproxy/log.h +++ b/include/haproxy/log.h @@ -246,6 +246,25 @@ static inline struct proxy *log_forward_by_name(const char *name) return NULL; } +/* Returns the name of the directive which assigned the proxy's current log + * format, for use in the warning emitted when it is overridden. Defaults to + * "log-format" for a format which is not one of the built-in ones. + */ +static inline const char *proxy_logformat_origin(const struct proxy *px) +{ + if (px->logformat.str == default_http_log_format) + return "option httplog"; + if (px->logformat.str == default_tcp_log_format) + return "option tcplog"; + if (px->logformat.str == clf_tcp_log_format) + return "option tcplog clf"; + if (px->logformat.str == clf_http_log_format) + return "option httplog clf"; + if (px->logformat.str == default_https_log_format) + return "option httpslog"; + return "log-format"; +} + #endif /* _HAPROXY_LOG_H */ /*