]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: trace: also report the trace level in the output
authorWilly Tarreau <w@1wt.eu>
Thu, 29 Aug 2019 07:08:36 +0000 (09:08 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 29 Aug 2019 15:11:25 +0000 (17:11 +0200)
It's very convenient to know the trace level in the output, at least to
grep/grep -v on it. The main usage is to filter/filter out the developer
traces at level DEVEL. For this we now add the numeric level (0 to 4) just
after the source name in the brackets. The output now looks like this :

  [00|h2|4|mux_h2.c:3174] h2_send(): entering : h2c=0x27d75a0 st=2
   -, -, | ------------,  --------,  -------------------> message
    |  | |             |          '-> function name
    |  | |             '-> source file location
    |  | '-> trace level (4=dev)
    |  '-> trace source
    '-> thread number

src/trace.c

index 63ad1f9b4711062e639b0583384d55a2d21ed207..6729f06b0684ebd2de5df1187990deb423c23b76 100644 (file)
@@ -87,7 +87,7 @@ void __trace(enum trace_level level, uint64_t mask, struct trace_source *src,
        const void *lockon_ptr = NULL;
        struct ist ist_func = ist(func);
        char tnum[4];
-       struct ist line[10];
+       struct ist line[12];
        int words = 0;
 
        if (likely(src->state == TRACE_STATE_STOPPED))
@@ -189,6 +189,8 @@ void __trace(enum trace_level level, uint64_t mask, struct trace_source *src,
        line[words++] = ist(tnum);
        line[words++] = src->name;
        line[words++] = ist("|");
+       line[words++] = ist2("01234" + level, 1); // "0" to "4"
+       line[words++] = ist("|");
        line[words] = where;
        if (line[words].len > 13) {
                line[words].ptr += (line[words].len - 13);