MINOR: traces: add a new level "error" below the "user" level
Sometimes it would be nice to be able to only trace abnormal events such
as protocol errors. Let's add a new "error" level below the "user" level
for this. This will allow to add TRACE_ERROR() at various error points
and only see them.
diff --git a/src/trace.c b/src/trace.c
index ae35ab4..3184354 100644
--- a/src/trace.c
+++ b/src/trace.c
@@ -408,7 +408,9 @@
if (!*name) {
chunk_printf(&trash, "Supported trace levels for source %s:\n", src->name.ptr);
- chunk_appendf(&trash, " %c user : information useful to the end user\n",
+ chunk_appendf(&trash, " %c error : report errors\n",
+ src->level == TRACE_LEVEL_ERROR ? '*' : ' ');
+ chunk_appendf(&trash, " %c user : also information useful to the end user\n",
src->level == TRACE_LEVEL_USER ? '*' : ' ');
chunk_appendf(&trash, " %c proto : also protocol-level updates\n",
src->level == TRACE_LEVEL_PROTO ? '*' : ' ');
@@ -422,7 +424,9 @@
return cli_msg(appctx, LOG_WARNING, trash.area);
}
- if (strcmp(name, "user") == 0)
+ if (strcmp(name, "error") == 0)
+ HA_ATOMIC_STORE(&src->level, TRACE_LEVEL_ERROR);
+ else if (strcmp(name, "user") == 0)
HA_ATOMIC_STORE(&src->level, TRACE_LEVEL_USER);
else if (strcmp(name, "proto") == 0)
HA_ATOMIC_STORE(&src->level, TRACE_LEVEL_PROTO);