From: Willy Tarreau Date: Mon, 12 Aug 2019 15:57:57 +0000 (+0200) Subject: MINOR: trace/cli: parse the "level" argument to configure the trace verbosity X-Git-Tag: v2.1-dev2~191 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=aaaf41140611e0c2e8f6b156f4c18a198ebf980c;p=thirdparty%2Fhaproxy.git MINOR: trace/cli: parse the "level" argument to configure the trace verbosity The "level" keyword allows to indicate the expected level of verbosity in the traces, among "user" (least verbose, just synthetic info) to "developer" (very detailed, including function entry/leaving). It's only displayed and set but not used yet. --- diff --git a/src/trace.c b/src/trace.c index dd59abe515..6d40fec638 100644 --- a/src/trace.c +++ b/src/trace.c @@ -106,7 +106,7 @@ static int cli_parse_trace(char **args, char *payload, struct appctx *appctx, vo "Supported commands:\n" " event : list/enable/disable source-specific event reporting\n" //" filter : list/enable/disable generic filters\n" - //" level : list/set detail level\n" + " level : list/set detail level\n" //" lock : automatic lock on thread/connection/stream/...\n" " pause : pause and automatically restart after a specific event\n" " sink : list/set event sinks\n" @@ -201,6 +201,38 @@ static int cli_parse_trace(char **args, char *payload, struct appctx *appctx, vo HA_ATOMIC_STORE(&src->sink, sink); } + else if (strcmp(args[2], "level") == 0) { + const char *name = args[3]; + + if (!*name) { + chunk_printf(&trash, "Supported detail levels for source %s:\n", src->name.ptr); + chunk_appendf(&trash, " %c user : information useful to the end user\n", + src->level == TRACE_LEVEL_USER ? '*' : ' '); + chunk_appendf(&trash, " %c payload : add information relevant to the payload\n", + src->level == TRACE_LEVEL_PAYLOAD ? '*' : ' '); + chunk_appendf(&trash, " %c proto : add information relevant to the protocol\n", + src->level == TRACE_LEVEL_PROTO ? '*' : ' '); + chunk_appendf(&trash, " %c state : add information relevant to the state machine\n", + src->level == TRACE_LEVEL_STATE ? '*' : ' '); + chunk_appendf(&trash, " %c developer : add information useful only to the developer\n", + src->level == TRACE_LEVEL_DEVELOPER ? '*' : ' '); + trash.area[trash.data] = 0; + return cli_msg(appctx, LOG_WARNING, trash.area); + } + + if (strcmp(name, "user") == 0) + HA_ATOMIC_STORE(&src->level, TRACE_LEVEL_USER); + else if (strcmp(name, "payload") == 0) + HA_ATOMIC_STORE(&src->level, TRACE_LEVEL_PAYLOAD); + else if (strcmp(name, "proto") == 0) + HA_ATOMIC_STORE(&src->level, TRACE_LEVEL_PROTO); + else if (strcmp(name, "state") == 0) + HA_ATOMIC_STORE(&src->level, TRACE_LEVEL_STATE); + else if (strcmp(name, "developer") == 0) + HA_ATOMIC_STORE(&src->level, TRACE_LEVEL_DEVELOPER); + else + return cli_err(appctx, "No such trace level"); + } else return cli_err(appctx, "Unknown trace keyword");