On Thu, 13 Mar 2014 10:48:01 -0400
Julien Vehent <[email protected]> wrote:
> Hi everyone,
>
> This seem to be a bug that I just ran into: when %ID is used in a
> log-format, but unique-id-format is not defined, then everything after
> %ID gets truncated from the logs.
>
> Example:
>
> == normal behavior
>
> haproxy.cfg:
> log-format %{+Q}r\ %ID\ "%B\ bytes"
> unique-id-format %{+X}o\ %ci:%cp_%fi:%fp_%Ts_%rt:%pid
>
> log:
> Mar 13 14:42:18 localhost haproxy[19447]: "GET
> /v1/somethingsomething HTTP/1.1"
> 47B4176E:A19C_0A977AE4:01BB_5321C3C9_000A:4BF7 "805 bytes"
>
> == broken behavior
>
> haproxy.cfg:
> log-format %{+Q}r\ %ID\ "%B\ bytes"
> # unique-id-format %{+X}o\ %ci:%cp_%fi:%fp_%Ts_%rt:%pid <=
> commented out
>
> log:
> Mar 13 14:45:46 localhost haproxy[19879]: "GET
> /v1/somethingsomething HTTP/1.1"
>
> The log line above stops after the request, and doesn't log the
> bytes_read %B.
>
> I may have missed something in the doc, but I haven't seen it mentioned
> anywhere.
Thanks for the bug repport. Can you try the attached patch. It seems to
resolve your problem.
Thanks
Thierry
> --
> Julien Vehent
> http://jve.linuxwall.info
>
diff --git a/src/log.c b/src/log.c
index 176a725..efb3d27 100644
--- a/src/log.c
+++ b/src/log.c
@@ -1559,8 +1559,7 @@ int build_logline(struct session *s, char *dst, size_t maxsize, struct list *lis
case LOG_FMT_UNIQUEID: // %ID
ret = NULL;
src = s->unique_id;
- if (src)
- ret = lf_text(tmplog, src, maxsize - (tmplog - dst), tmp);
+ ret = lf_text(tmplog, src, maxsize - (tmplog - dst), tmp);
if (ret == NULL)
goto out;
tmplog = ret;