mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 06:11:32 +02:00
MINOR: server: respect warning and alert semantic
Error codes ERR_WARN and ERR_ALERT are used to signal that the error given is of the corresponding level. All errors are displayed as ALERT in the display_parser_err() function. Differentiate the display level based on the error code. If both ERR_WARN and ERR_ALERT are used, ERR_ALERT is given priority.
This commit is contained in:
parent
8acb1284bc
commit
10c4b4a795
24
src/server.c
24
src/server.c
@ -1569,15 +1569,27 @@ static int server_parse_sni_expr(struct server *newsrv, struct proxy *px, char *
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void display_parser_err(const char *file, int linenum, char **args, int cur_arg, char **err)
|
static void display_parser_err(const char *file, int linenum, char **args, int cur_arg, int err_code, char **err)
|
||||||
{
|
{
|
||||||
|
char *msg = "error encountered while processing ";
|
||||||
|
char *quote = "'";
|
||||||
|
char *token = args[cur_arg];
|
||||||
|
|
||||||
if (err && *err) {
|
if (err && *err) {
|
||||||
indent_msg(err, 2);
|
indent_msg(err, 2);
|
||||||
ha_alert("parsing [%s:%d] : '%s %s' : %s\n", file, linenum, args[0], args[1], *err);
|
msg = *err;
|
||||||
|
quote = "";
|
||||||
|
token = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (err_code & ERR_WARN && !(err_code & ERR_ALERT))
|
||||||
|
ha_warning("parsing [%s:%d] : '%s %s' : %s%s%s%s.\n",
|
||||||
|
file, linenum, args[0], args[1],
|
||||||
|
msg, quote, token, quote);
|
||||||
else
|
else
|
||||||
ha_alert("parsing [%s:%d] : '%s %s' : error encountered while processing '%s'.\n",
|
ha_alert("parsing [%s:%d] : '%s %s' : %s%s%s%s.\n",
|
||||||
file, linenum, args[0], args[1], args[cur_arg]);
|
file, linenum, args[0], args[1],
|
||||||
|
msg, quote, token, quote);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void srv_conn_src_sport_range_cpy(struct server *srv,
|
static void srv_conn_src_sport_range_cpy(struct server *srv,
|
||||||
@ -2030,7 +2042,7 @@ static int server_sni_expr_init(const char *file, int linenum, char **args, int
|
|||||||
if (!ret)
|
if (!ret)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
display_parser_err(file, linenum, args, cur_arg, &err);
|
display_parser_err(file, linenum, args, cur_arg, ret, &err);
|
||||||
free(err);
|
free(err);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -2834,7 +2846,7 @@ int parse_server(const char *file, int linenum, char **args, struct proxy *curpr
|
|||||||
err_code |= code;
|
err_code |= code;
|
||||||
|
|
||||||
if (code) {
|
if (code) {
|
||||||
display_parser_err(file, linenum, args, cur_arg, &err);
|
display_parser_err(file, linenum, args, cur_arg, code, &err);
|
||||||
if (code & ERR_FATAL) {
|
if (code & ERR_FATAL) {
|
||||||
free(err);
|
free(err);
|
||||||
if (kw->skip != -1)
|
if (kw->skip != -1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user