mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-06 15:17:01 +02:00
MINOR: log: postpone conversion for sample expressions in sess_build_logline()
In sess_build_logline(), for sample expression nodes, instead of directly calling sample_fetch_as_type(... SMP_T_STR), let's first process the sample using sample_process(), and then proceed with the conversion to str if required. Doing so will allow us to implement type casting and preserving logic.
This commit is contained in:
parent
84963fb743
commit
fb8b47fed8
15
src/log.c
15
src/log.c
@ -3218,15 +3218,23 @@ int sess_build_logline(struct session *sess, struct stream *s, char *dst, size_t
|
||||
break;
|
||||
|
||||
case LOG_FMT_EXPR: // sample expression, may be request or response
|
||||
{
|
||||
int type;
|
||||
|
||||
key = NULL;
|
||||
if (ctx.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);
|
||||
key = sample_process(be, sess, s, SMP_OPT_DIR_REQ|SMP_OPT_FINAL, tmp->expr, NULL);
|
||||
|
||||
if (!key && (ctx.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);
|
||||
key = sample_process(be, sess, s, SMP_OPT_DIR_RES|SMP_OPT_FINAL, tmp->expr, NULL);
|
||||
|
||||
if (!key && !(ctx.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);
|
||||
key = sample_process(be, sess, s, SMP_OPT_FINAL, tmp->expr, NULL);
|
||||
|
||||
type = SMP_T_STR; // default
|
||||
|
||||
if (key && !sample_convert(key, type))
|
||||
key = NULL;
|
||||
|
||||
if (ctx.options & LOG_OPT_HTTP)
|
||||
ret = lf_encode_chunk(tmplog, dst + maxsize,
|
||||
@ -3241,6 +3249,7 @@ int sess_build_logline(struct session *sess, struct stream *s, char *dst, size_t
|
||||
goto out;
|
||||
tmplog = ret;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (tmp->type != LOG_FMT_TAG)
|
||||
|
Loading…
Reference in New Issue
Block a user