From 7ff26271122fd3e12ab782a1ad0167f22d913ae9 Mon Sep 17 00:00:00 2001 From: Tim Duesterhus Date: Mon, 13 Apr 2026 19:37:29 +0200 Subject: [PATCH] CLEANUP: log: Stop touching `struct stream` internals for `%ID` Use the return value of `stream_generate_unique_id()` instead of relying on the `unique_id` field of `struct stream` when handling the `%ID` log placeholder. This also allowed to unify the "stream available" and "stream not available" paths. Reviewed-by: Volker Dusch --- src/log.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/log.c b/src/log.c index 8d51f0c93..b669be627 100644 --- a/src/log.c +++ b/src/log.c @@ -5171,20 +5171,18 @@ size_t sess_build_logline_orig(struct session *sess, struct stream *s, break; case LOG_FMT_UNIQUEID: // %ID - ret = NULL; - if (s) { - /* if unique-id was not generated */ - if (!isttest(s->unique_id) && !lf_expr_isempty(&sess->fe->format_unique_id)) { - stream_generate_unique_id(s, &sess->fe->format_unique_id); - } - ret = lf_text_len(tmplog, s->unique_id.ptr, s->unique_id.len, maxsize - (tmplog - dst), ctx); - } - else - ret = lf_text_len(tmplog, NULL, 0, maxsize - (tmplog - dst), ctx); + { + struct ist unique_id = IST_NULL; + + if (s && !lf_expr_isempty(&sess->fe->format_unique_id)) + unique_id = stream_generate_unique_id(s, &sess->fe->format_unique_id); + + ret = lf_text_len(tmplog, istptr(unique_id), istlen(unique_id), maxsize - (tmplog - dst), ctx); if (ret == NULL) goto out; tmplog = ret; break; + } case LOG_FMT_ORIGIN: // %OG ret = lf_text(tmplog, log_orig_to_str(log_orig.id),