From: Willy Tarreau Date: Fri, 3 Sep 2021 06:53:29 +0000 (+0200) Subject: MINOR: log: make log-format expressions completely usable outside of req/resp X-Git-Tag: v2.5-dev6~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=20b7a0f9ed0c4f2aefa0d170b26610d37b740445;p=thirdparty%2Fhaproxy.git MINOR: log: make log-format expressions completely usable outside of req/resp The log-format strings are usable at plenty of places, but the expressions using %[] were restricted to request or response context and nothing else. This prevents from using them from the config context or the CLI, let's relax this. --- diff --git a/src/log.c b/src/log.c index 18040627ec..5cae18293d 100644 --- a/src/log.c +++ b/src/log.c @@ -2075,8 +2075,13 @@ int sess_build_logline(struct session *sess, struct stream *s, char *dst, size_t key = NULL; if (tmp->options & LOG_OPT_REQ_CAP) key = sample_fetch_as_type(be, sess, s, SMP_OPT_DIR_REQ|SMP_OPT_FINAL, tmp->expr, SMP_T_STR); + if (!key && (tmp->options & LOG_OPT_RES_CAP)) key = sample_fetch_as_type(be, sess, s, SMP_OPT_DIR_RES|SMP_OPT_FINAL, tmp->expr, SMP_T_STR); + + if (!key && !(tmp->options & (LOG_OPT_REQ_CAP|LOG_OPT_RES_CAP))) // cfg, cli + key = sample_fetch_as_type(be, sess, s, SMP_OPT_FINAL, tmp->expr, SMP_T_STR); + if (tmp->options & LOG_OPT_HTTP) ret = lf_encode_chunk(tmplog, dst + maxsize, '%', http_encode_map, key ? &key->data.u.str : &empty, tmp);