From 20b7a0f9ed0c4f2aefa0d170b26610d37b740445 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 3 Sep 2021 08:53:29 +0200 Subject: [PATCH] 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. --- src/log.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/log.c b/src/log.c index 1804062..5cae182 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); -- 1.7.10.4