Commit Graph

13 Commits

Author SHA1 Message Date
Willy Tarreau
e0b3a8b5a2 BUILD: halog: fix some incorrect signs in printf formats for integers
In issue #1184, cppcheck found several issues in the printf formats
used to display integers, some of which are unsigned but which used to
still rely on "%d".
2022-04-12 08:40:38 +02:00
Willy Tarreau
e9f4d67b15 OPTIM: halog: skip fields 64 bits at a time when supported
Some architectures like x86_64 and aarch64 support efficient unaligned
64-bit reads. On such architectures, we already know that each string
passed to field_start() has some margin at the end because it's parsed
using fgets2() which looks for the trailing LF using the same method.
Thus let's skip spaces by packs of 8. This increases the parsing speed
by 35%.
2021-11-08 12:08:26 +01:00
Willy Tarreau
fc76bbc0f5 OPTIM: halog: improve field parser speed for modern compilers
Modern compilers were producing producing less efficient code in the
field_start() loop, by not emitting two conditional jumps for a single
test. However by reordering the test we can merge the optimal case and
the default one and get back to good performance so let's simplify the
test. This improves the parsing speed by 5%.
2021-11-08 12:08:26 +01:00
Willy Tarreau
fce4e69144 CLEANUP: halog: remove unused strl2ui()
strl2ui() isn't used anymore in the code, likely because str2ic() is
often used instead. Let's drop it.
2021-11-08 12:08:26 +01:00
Willy Tarreau
87e7eafde4 CLEANUP: halog: make the default usage message fit in small screens
The usage message was starting to have long lines, it's preferable that
it still fits well into a default 80-col display so that options are
easy to find. Also cut that into the 3 parts (input filter, modifier,
output format) for improved legibility.
2021-11-08 08:39:28 +01:00
Tim Duesterhus
785b84bb8f CLEANUP: halog: Remove dead stores
Found using clang's scan-build.
2021-11-05 07:48:38 +01:00
Tim Duesterhus
66255f7bbf MINOR: halog: Add support for extracting captures using -hdr
This patch adds support for extracting captured header fields to halog. A field
can be extracted by passing the `-hdr <block>:<field>` output filter.

Both `<block>` and `<field>` are 1-indexed.

`<block>` refers to the index of the brace-delimited list of headers. If both
request and response headers are captured, then request headers are referenced
by `<block> = 1`, response headers are `2`. If only one direction is captured,
there will only be a single block `1`.

`<field>` refers to a single field within the selected block.

The output will contain one line, possibly empty, per log line processed.
Passing a non-existent `<block>` or `<field>` will result in an empty line.

Example:

    capture request  header a len 50
    capture request  header b len 50
    capture request  header c len 50
    capture response header d len 50
    capture response header e len 50
    capture response header f len 50

`-srv 1:1` will extract request  header `a`
`-srv 1:2` will extract request  header `b`
`-srv 1:3` will extract request  header `c`
`-srv 2:3` will extract response header `f`

This resolves GitHub issue #1146.
2021-10-28 19:44:18 +02:00
Tim Duesterhus
a02c7b882f BUG/MINOR: halog: Add missing newlines in die() messages
This newline is required to correctly print the usage.
2021-10-28 18:50:51 +02:00
Tim Duesterhus
e0992584b9 CLEANUP: halog: Use consistent indentation in help()
Consistently use 1 Tab per line.
2021-10-28 18:50:34 +02:00
Tim Duesterhus
385338b30b MINOR: halog: Rename -qry to -query
With the query flag moved into the correct help section, there is enough space
for two additional characters.
2021-10-28 18:50:07 +02:00
Tim Duesterhus
a0635f8d10 DOC: halog: Move the -qry parameter into the correct section in help text
This is not an output filter, but instead a modifier. Specifically "only one
may be used at a time" is not true.

see 24b8d693b2
2021-10-28 18:49:51 +02:00
Tim Duesterhus
24b8d693b2 MINOR: halog: Add -qry parameter allowing to preserve the query string in -uX
Our use-case for this is a dynamic application that performs routing based on
the query string. Without this option all URLs will just point to the central
entrypoint of this location, making the output completely useless.
2021-10-28 09:45:44 +02:00
Willy Tarreau
d798889a5d CONTRIB: move halog to admin/
halog is an admin tool, so let's move it to admin/ as well. The makefile
was updated to build from the new directory.
2021-04-02 17:48:42 +02:00