From 052ad360cd9b34570c28cead539b74a1ebfef353 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 29 Aug 2019 09:08:36 +0200 Subject: [PATCH] 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 --- src/trace.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/trace.c b/src/trace.c index 63ad1f9b4..6729f06b0 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);