mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 07:37:02 +02:00
MINOR: log: store lf_expr nodes inside substruct
Add another struct level inside lf_expr struct to allow new information to be stored alongside lf_expr nodes.
This commit is contained in:
parent
f8e1357a05
commit
7ff4f09e23
@ -175,14 +175,16 @@ enum lf_expr_flags {
|
|||||||
|
|
||||||
/* a full logformat expr made of one or multiple logformat nodes */
|
/* a full logformat expr made of one or multiple logformat nodes */
|
||||||
struct lf_expr {
|
struct lf_expr {
|
||||||
struct list list; /* to store lf_expr inside a list */
|
struct list list; /* to store lf_expr inside a list */
|
||||||
union {
|
union {
|
||||||
struct list nodes; /* logformat_node list */
|
struct {
|
||||||
char *str; /* original string prior to parsing (NULL once compiled) */
|
struct list list; /* logformat_node list */
|
||||||
|
} nodes;
|
||||||
|
char *str; /* original string prior to parsing (NULL once compiled) */
|
||||||
};
|
};
|
||||||
struct {
|
struct {
|
||||||
char *file; /* file where the lft appears */
|
char *file; /* file where the lft appears */
|
||||||
int line; /* line where the lft appears */
|
int line; /* line where the lft appears */
|
||||||
} conf; // parsing hints
|
} conf; // parsing hints
|
||||||
uint8_t flags; /* LF_FL_* flags */
|
uint8_t flags; /* LF_FL_* flags */
|
||||||
};
|
};
|
||||||
|
@ -70,7 +70,7 @@ void lf_expr_xfer(struct lf_expr *src, struct lf_expr *dst);
|
|||||||
void lf_expr_deinit(struct lf_expr *expr);
|
void lf_expr_deinit(struct lf_expr *expr);
|
||||||
static inline int lf_expr_isempty(const struct lf_expr *expr)
|
static inline int lf_expr_isempty(const struct lf_expr *expr)
|
||||||
{
|
{
|
||||||
return !(expr->flags & LF_FL_COMPILED) || LIST_ISEMPTY(&expr->nodes);
|
return !(expr->flags & LF_FL_COMPILED) || LIST_ISEMPTY(&expr->nodes.list);
|
||||||
}
|
}
|
||||||
int lf_expr_compile(struct lf_expr *lf_expr, struct arg_list *al, int options, int cap, char **err);
|
int lf_expr_compile(struct lf_expr *lf_expr, struct arg_list *al, int options, int cap, char **err);
|
||||||
int lf_expr_postcheck(struct lf_expr *lf_expr, struct proxy *px, char **err);
|
int lf_expr_postcheck(struct lf_expr *lf_expr, struct proxy *px, char **err);
|
||||||
|
@ -3164,10 +3164,10 @@ int check_config_validity()
|
|||||||
cfgerr++;
|
cfgerr++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
node = LIST_NEXT(&rule->be.expr.nodes, struct logformat_node *, list);
|
node = LIST_NEXT(&rule->be.expr.nodes.list, struct logformat_node *, list);
|
||||||
|
|
||||||
if (!lf_expr_isempty(&rule->be.expr)) {
|
if (!lf_expr_isempty(&rule->be.expr)) {
|
||||||
if (node->type != LOG_FMT_TEXT || node->list.n != &rule->be.expr.nodes) {
|
if (node->type != LOG_FMT_TEXT || node->list.n != &rule->be.expr.nodes.list) {
|
||||||
rule->dynamic = 1;
|
rule->dynamic = 1;
|
||||||
free(pxname);
|
free(pxname);
|
||||||
/* backend is not yet known so we cannot assume its type,
|
/* backend is not yet known so we cannot assume its type,
|
||||||
@ -3238,10 +3238,10 @@ int check_config_validity()
|
|||||||
cfgerr++;
|
cfgerr++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
node = LIST_NEXT(&srule->expr.nodes, struct logformat_node *, list);
|
node = LIST_NEXT(&srule->expr.nodes.list, struct logformat_node *, list);
|
||||||
|
|
||||||
if (!lf_expr_isempty(&srule->expr)) {
|
if (!lf_expr_isempty(&srule->expr)) {
|
||||||
if (node->type != LOG_FMT_TEXT || node->list.n != &srule->expr.nodes) {
|
if (node->type != LOG_FMT_TEXT || node->list.n != &srule->expr.nodes.list) {
|
||||||
srule->dynamic = 1;
|
srule->dynamic = 1;
|
||||||
free(server_name);
|
free(server_name);
|
||||||
continue;
|
continue;
|
||||||
|
20
src/log.c
20
src/log.c
@ -407,7 +407,7 @@ static int parse_logformat_tag(char *arg, int arg_len, char *name, int name_len,
|
|||||||
int *defoptions, char **err)
|
int *defoptions, char **err)
|
||||||
{
|
{
|
||||||
int j;
|
int j;
|
||||||
struct list *list_format= &lf_expr->nodes;
|
struct list *list_format= &lf_expr->nodes.list;
|
||||||
struct logformat_node *node = NULL;
|
struct logformat_node *node = NULL;
|
||||||
|
|
||||||
for (j = 0; logformat_tags[j].name; j++) { // search a log type
|
for (j = 0; logformat_tags[j].name; j++) { // search a log type
|
||||||
@ -462,7 +462,7 @@ static int parse_logformat_tag(char *arg, int arg_len, char *name, int name_len,
|
|||||||
*/
|
*/
|
||||||
int add_to_logformat_list(char *start, char *end, int type, struct lf_expr *lf_expr, char **err)
|
int add_to_logformat_list(char *start, char *end, int type, struct lf_expr *lf_expr, char **err)
|
||||||
{
|
{
|
||||||
struct list *list_format = &lf_expr->nodes;
|
struct list *list_format = &lf_expr->nodes.list;
|
||||||
char *str;
|
char *str;
|
||||||
|
|
||||||
if (type == LF_TEXT) { /* type text */
|
if (type == LF_TEXT) { /* type text */
|
||||||
@ -502,7 +502,7 @@ static int add_sample_to_logformat_list(char *text, char *name, int name_len, in
|
|||||||
struct arg_list *al, int options, int cap, char **err, char **endptr)
|
struct arg_list *al, int options, int cap, char **err, char **endptr)
|
||||||
{
|
{
|
||||||
char *cmd[2];
|
char *cmd[2];
|
||||||
struct list *list_format = &lf_expr->nodes;
|
struct list *list_format = &lf_expr->nodes.list;
|
||||||
struct sample_expr *expr = NULL;
|
struct sample_expr *expr = NULL;
|
||||||
struct logformat_node *node = NULL;
|
struct logformat_node *node = NULL;
|
||||||
int cmd_arg;
|
int cmd_arg;
|
||||||
@ -608,7 +608,7 @@ int lf_expr_compile(struct lf_expr *lf_expr,
|
|||||||
* been saved as local 'fmt' string pointer, so we must free it before
|
* been saved as local 'fmt' string pointer, so we must free it before
|
||||||
* returning.
|
* returning.
|
||||||
*/
|
*/
|
||||||
LIST_INIT(&lf_expr->nodes);
|
LIST_INIT(&lf_expr->nodes.list);
|
||||||
/* we must set the compiled flag now for proper deinit in case of failure */
|
/* we must set the compiled flag now for proper deinit in case of failure */
|
||||||
lf_expr->flags |= LF_FL_COMPILED;
|
lf_expr->flags |= LF_FL_COMPILED;
|
||||||
|
|
||||||
@ -874,7 +874,7 @@ int lf_expr_postcheck(struct lf_expr *lf_expr, struct proxy *px, char **err)
|
|||||||
if (!(px->flags & PR_FL_CHECKED))
|
if (!(px->flags & PR_FL_CHECKED))
|
||||||
px->to_log |= LW_INIT;
|
px->to_log |= LW_INIT;
|
||||||
|
|
||||||
list_for_each_entry(lf, &lf_expr->nodes, list) {
|
list_for_each_entry(lf, &lf_expr->nodes.list, list) {
|
||||||
if (lf->type == LOG_FMT_EXPR) {
|
if (lf->type == LOG_FMT_EXPR) {
|
||||||
struct sample_expr *expr = lf->expr;
|
struct sample_expr *expr = lf->expr;
|
||||||
uint8_t http_needed = !!(expr->fetch->use & SMP_USE_HTTP_ANY);
|
uint8_t http_needed = !!(expr->fetch->use & SMP_USE_HTTP_ANY);
|
||||||
@ -2801,7 +2801,7 @@ void lf_expr_init(struct lf_expr *expr)
|
|||||||
void lf_expr_deinit(struct lf_expr *expr)
|
void lf_expr_deinit(struct lf_expr *expr)
|
||||||
{
|
{
|
||||||
if ((expr->flags & LF_FL_COMPILED))
|
if ((expr->flags & LF_FL_COMPILED))
|
||||||
free_logformat_list(&expr->nodes);
|
free_logformat_list(&expr->nodes.list);
|
||||||
else
|
else
|
||||||
logformat_str_free(&expr->str);
|
logformat_str_free(&expr->str);
|
||||||
free(expr->conf.file);
|
free(expr->conf.file);
|
||||||
@ -2828,11 +2828,11 @@ void lf_expr_xfer(struct lf_expr *src, struct lf_expr *dst)
|
|||||||
dst->conf.line = src->conf.line;
|
dst->conf.line = src->conf.line;
|
||||||
|
|
||||||
dst->flags |= LF_FL_COMPILED;
|
dst->flags |= LF_FL_COMPILED;
|
||||||
LIST_INIT(&dst->nodes);
|
LIST_INIT(&dst->nodes.list);
|
||||||
|
|
||||||
list_for_each_entry_safe(lf, lfb, &src->nodes, list) {
|
list_for_each_entry_safe(lf, lfb, &src->nodes.list, list) {
|
||||||
LIST_DELETE(&lf->list);
|
LIST_DELETE(&lf->list);
|
||||||
LIST_APPEND(&dst->nodes, &lf->list);
|
LIST_APPEND(&dst->nodes.list, &lf->list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* replace <src> with <dst> in <src>'s list by first adding
|
/* replace <src> with <dst> in <src>'s list by first adding
|
||||||
@ -2885,7 +2885,7 @@ int sess_build_logline(struct session *sess, struct stream *s, char *dst, size_t
|
|||||||
struct http_txn *txn;
|
struct http_txn *txn;
|
||||||
const struct strm_logs *logs;
|
const struct strm_logs *logs;
|
||||||
struct connection *fe_conn, *be_conn;
|
struct connection *fe_conn, *be_conn;
|
||||||
struct list *list_format = &lf_expr->nodes;
|
struct list *list_format = &lf_expr->nodes.list;
|
||||||
unsigned int s_flags;
|
unsigned int s_flags;
|
||||||
unsigned int uniq_id;
|
unsigned int uniq_id;
|
||||||
struct buffer chunk;
|
struct buffer chunk;
|
||||||
|
Loading…
Reference in New Issue
Block a user