From: Aurelien DARRAGON Date: Tue, 14 May 2024 15:05:30 +0000 (+0200) Subject: MINOR: log: provide proxy context to resolve_logger() X-Git-Tag: v3.1-dev1~19 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3102c89dde4c49d4f65840f2fd8298da1455f751;p=thirdparty%2Fhaproxy.git MINOR: log: provide proxy context to resolve_logger() Prerequisite work for log-profiles, we need to know under which proxy context the logger is being used. When the info is not available, (ie: global section or log-forward section, is set to NULL) --- diff --git a/include/haproxy/log.h b/include/haproxy/log.h index 48b363dd43..c08a11c319 100644 --- a/include/haproxy/log.h +++ b/include/haproxy/log.h @@ -129,7 +129,7 @@ ssize_t syslog_applet_append_event(void *ctx, struct ist v1, struct ist v2, size */ int parse_logformat_string(const char *str, struct proxy *curproxy, struct lf_expr *lf_expr, int options, int cap, char **err); -int postresolve_logger_list(struct list *loggers, const char *section, const char *section_name); +int postresolve_logger_list(struct proxy *px, struct list *loggers, const char *section, const char *section_name); struct logger *dup_logger(struct logger *def); void free_logger(struct logger *logger); diff --git a/src/fcgi-app.c b/src/fcgi-app.c index e8117a3328..5790cebcf8 100644 --- a/src/fcgi-app.c +++ b/src/fcgi-app.c @@ -691,7 +691,7 @@ static int cfg_fcgi_apps_postparser() curapp->maxreqs = 1; } - err_code |= postresolve_logger_list(&curapp->loggers, "fcgi-app", curapp->name); + err_code |= postresolve_logger_list(NULL, &curapp->loggers, "fcgi-app", curapp->name); } end: diff --git a/src/flt_spoe.c b/src/flt_spoe.c index 95930f13f2..f565e962dc 100644 --- a/src/flt_spoe.c +++ b/src/flt_spoe.c @@ -3110,7 +3110,7 @@ spoe_check(struct proxy *px, struct flt_conf *fconf) HA_SPIN_INIT(&conf->agent->rt[i].lock); } - if (postresolve_logger_list(&conf->agent_fe.loggers, "SPOE agent", conf->agent->id) & ERR_CODE) + if (postresolve_logger_list(NULL, &conf->agent_fe.loggers, "SPOE agent", conf->agent->id) & ERR_CODE) return 1; ha_free(&conf->agent->b.name); diff --git a/src/log.c b/src/log.c index d4e4932714..974795319d 100644 --- a/src/log.c +++ b/src/log.c @@ -1406,13 +1406,15 @@ static int postcheck_log_backend(struct proxy *be) /* resolves a single logger entry (it is expected to be called * at postparsing stage) * + * is parent proxy, used for context (may be NULL) + * * Returns err_code which defaults to ERR_NONE and can be set to a combination * of ERR_WARN, ERR_ALERT, ERR_FATAL and ERR_ABORT in case of errors. * could be set at any time (it will usually be set on error, but * could also be set when no error occurred to report a diag warning), thus is * up to the caller to check it and to free it. */ -static int resolve_logger(struct logger *logger, char **msg) +static int resolve_logger(struct proxy *px, struct logger *logger, char **msg) { struct log_target *target = &logger->target; int err_code = ERR_NONE; @@ -5882,7 +5884,8 @@ out: * Returns err_code which defaults to ERR_NONE and can be set to a combination * of ERR_WARN, ERR_ALERT, ERR_FATAL and ERR_ABORT in case of errors. */ -int postresolve_logger_list(struct list *loggers, const char *section, const char *section_name) +int postresolve_logger_list(struct proxy *px, struct list *loggers, + const char *section, const char *section_name) { int err_code = ERR_NONE; struct logger *logger; @@ -5891,7 +5894,7 @@ int postresolve_logger_list(struct list *loggers, const char *section, const cha int cur_code; char *msg = NULL; - cur_code = resolve_logger(logger, &msg); + cur_code = resolve_logger(px, logger, &msg); if (msg) { void (*e_func)(const char *fmt, ...) = NULL; @@ -5923,13 +5926,13 @@ static int postresolve_loggers() int err_code = ERR_NONE; /* global log directives */ - err_code |= postresolve_logger_list(&global.loggers, NULL, NULL); + err_code |= postresolve_logger_list(NULL, &global.loggers, NULL, NULL); /* proxy log directives */ for (px = proxies_list; px; px = px->next) - err_code |= postresolve_logger_list(&px->loggers, "proxy", px->id); + err_code |= postresolve_logger_list(px, &px->loggers, "proxy", px->id); /* log-forward log directives */ for (px = cfg_log_forward; px; px = px->next) - err_code |= postresolve_logger_list(&px->loggers, "log-forward", px->id); + err_code |= postresolve_logger_list(NULL, &px->loggers, "log-forward", px->id); return err_code; }