From: Aurelien DARRAGON Date: Wed, 4 Sep 2024 10:15:21 +0000 (+0200) Subject: MINOR: log: add log_orig_proxy() helper function X-Git-Tag: v3.1-dev9~43 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4189eb7aca7606547428ab314fd43593ab1ab7ed;p=thirdparty%2Fhaproxy.git MINOR: log: add log_orig_proxy() helper function Function may be used on proxy where log-steps are used to check if a given log origin should be handled or not. --- diff --git a/include/haproxy/log.h b/include/haproxy/log.h index 86f5b9c5f6..bb4d5f6947 100644 --- a/include/haproxy/log.h +++ b/include/haproxy/log.h @@ -66,6 +66,7 @@ int init_log_buffers(void); void deinit_log_buffers(void); const char *log_orig_to_str(enum log_orig_id orig); +int log_orig_proxy(enum log_orig_id orig, struct proxy *px); void lf_expr_init(struct lf_expr *expr); int lf_expr_dup(const struct lf_expr *orig, struct lf_expr *dest); diff --git a/src/log.c b/src/log.c index 9e01ea3d19..0f35aa2098 100644 --- a/src/log.c +++ b/src/log.c @@ -128,6 +128,27 @@ const char *log_orig_to_str(enum log_orig_id orig) return "unspec"; } +/* Check if log origin is set for logging on + * + * It is assumed that the caller already checked that log-steps were + * enabled on the proxy (do_log special value LW_LOGSTEPS) + * + * Returns 1 for true and 0 for false + */ +int log_orig_proxy(enum log_orig_id orig, struct proxy *px) +{ + if (eb_is_empty(&px->conf.log_steps)) { + /* empty tree means all log steps are enabled, thus + * all log origins are considered + */ + return 1; + } + /* selectively check if the current log origin is referenced in + * proxy log-steps + */ + return !!eb32_lookup(&px->conf.log_steps, orig); +} + /* * This map is used with all the FD_* macros to check whether a particular bit * is set or not. Each bit represents an ASCII code. ha_bit_set() sets those