CLEANUP: log: add a macro to know if a lf_node is configurable

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.
This commit is contained in:
Aurelien DARRAGON 2024-04-29 12:22:56 +02:00
parent 98b44e8edb
commit 9bdce67585
2 changed files with 6 additions and 2 deletions

View 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

View File

@ -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)