MINOR: http/conf: store the use_backend configuration file and line for logs

The error log of the directive use_backend doesn't provide the
file and line containing the declaration. This patch stores
theses informations.
This commit is contained in:
Thierry FOURNIER / OZON.IO 2016-11-24 23:57:54 +01:00 committed by Willy Tarreau
parent 5948b01149
commit 4ed1c9585d
5 changed files with 15 additions and 0 deletions

View File

@ -77,6 +77,7 @@ enum {
ARGC_CAP, /* capture rule */
ARGC_SRV, /* server line */
ARGC_SPOE, /* spoe message args */
ARGC_UBK, /* use_backend message */
};
/* flags used when compiling and executing regex */

View File

@ -446,6 +446,8 @@ struct switching_rule {
char *name; /* target backend name during config parsing */
struct list expr; /* logformat expression to use for dynamic rules */
} be;
char *file;
int line;
};
struct server_rule {

View File

@ -4018,6 +4018,12 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
}
rule->cond = cond;
rule->be.name = strdup(args[1]);
rule->line = linenum;
rule->file = strdup(file);
if (!rule->file) {
Alert("Out of memory error.\n");
goto out;
}
LIST_INIT(&rule->list);
LIST_ADDQ(&curproxy->switching_rules, &rule->list);
}
@ -7792,6 +7798,9 @@ int check_config_validity()
*/
pxname = rule->be.name;
LIST_INIT(&rule->be.expr);
curproxy->conf.args.ctx = ARGC_UBK;
curproxy->conf.args.file = rule->file;
curproxy->conf.args.line = rule->line;
if (!parse_logformat_string(pxname, curproxy, &rule->be.expr, 0, SMP_VAL_FE_HRQ_HDR)) {
cfgerr++;
continue;

View File

@ -1482,6 +1482,7 @@ void deinit(void)
if (rule->cond) {
prune_acl_cond(rule->cond);
free(rule->cond);
free(rule->file);
}
free(rule);
}

View File

@ -269,6 +269,8 @@ static inline const char *fmt_directive(const struct proxy *curproxy)
return "server";
case ARGC_SPOE:
return "spoe-message";
case ARGC_UBK:
return "use_backend";
default:
return "undefined(please report this bug)"; /* must never happen */
}