]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: trace/cli: parse the "level" argument to configure the trace verbosity
authorWilly Tarreau <w@1wt.eu>
Mon, 12 Aug 2019 15:57:57 +0000 (17:57 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 22 Aug 2019 18:21:00 +0000 (20:21 +0200)
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.

src/trace.c

index dd59abe5156bb36a09647afdbc47937131625c93..6d40fec638be26ed0d9bac3178b107b8fd52653c 100644 (file)
@@ -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");