From: Willy Tarreau Date: Thu, 29 Aug 2019 07:08:36 +0000 (+0200) Subject: MINOR: trace: also report the trace level in the output X-Git-Tag: v2.1-dev2~150 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=052ad360cd9b34570c28cead539b74a1ebfef353;p=thirdparty%2Fhaproxy.git MINOR: trace: also report the trace level in the output 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 --- diff --git a/src/trace.c b/src/trace.c index 63ad1f9b47..6729f06b06 100644 --- a/src/trace.c +++ b/src/trace.c @@ -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);