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
This commit is contained in:
Willy Tarreau 2019-08-29 09:08:36 +02:00
parent 09fb0df6fd
commit 052ad360cd

View File

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