]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: log: add a macro to know if a lf_node is configurable
authorAurelien DARRAGON <adarragon@haproxy.com>
Mon, 29 Apr 2024 10:22:56 +0000 (12:22 +0200)
committerAurelien DARRAGON <adarragon@haproxy.com>
Mon, 29 Apr 2024 12:47:37 +0000 (14:47 +0200)
LF_NODE_WITH_OPT(node) returns true if the node's option may be set and
thus should be considered. Logic is based on logformat node's type:
for now only TAG and FMT nodes can be configured.

include/haproxy/log-t.h
src/log.c

index dae5067e54ce56722f51a2c0bd51e207aeab20f9..f5639687499fe60dabbd588ea53f2e3dfb0da8eb 100644 (file)
@@ -174,6 +174,10 @@ struct logformat_node {
        const struct logformat_tag *tag; // set if ->type == LOG_FMT_TAG
 };
 
+/* returns true if the node options may be set (according to it's type) */
+#define LF_NODE_WITH_OPT(node) \
+  (node->type == LOG_FMT_EXPR || node->type == LOG_FMT_TAG)
+
 enum lf_expr_flags {
        LF_FL_NONE     = 0x00,
        LF_FL_COMPILED = 0x01
index a7cc713fcae3f526768c0825395b38266756b044..2cde788313449a41a226bb416f5dfd8247d3667d 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -932,7 +932,7 @@ int lf_expr_postcheck(struct lf_expr *lf_expr, struct proxy *px, char **err)
                                px->to_log |= lf->tag->lw;
                }
  next_node:
-               if (lf->type == LOG_FMT_EXPR || lf->type == LOG_FMT_TAG) {
+               if (LF_NODE_WITH_OPT(lf)) {
                        /* For configurable nodes, apply current node's option
                         * mask to global node options to keep options common
                         * to all nodes
@@ -3642,7 +3642,7 @@ int sess_build_logline(struct session *sess, struct stream *s, char *dst, size_t
                        /* types that cannot be named such as text or separator are ignored
                         * when encoding is set
                         */
-                       if (tmp->type != LOG_FMT_EXPR && tmp->type != LOG_FMT_TAG)
+                       if (!LF_NODE_WITH_OPT(tmp))
                                goto next_fmt;
 
                        if (!tmp->name)