mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-18 11:40:50 +00:00
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.
This commit is contained in:
parent
a307528fe2
commit
a1f12746b1
@ -79,7 +79,8 @@ enum trace_state {
|
||||
* lower level are always reported at higher levels.
|
||||
*/
|
||||
enum trace_level {
|
||||
TRACE_LEVEL_USER = 0, // info useful to the end user
|
||||
TRACE_LEVEL_ERROR = 0, // only errors
|
||||
TRACE_LEVEL_USER, // also info useful to the end user
|
||||
TRACE_LEVEL_PROTO, // also report protocol-level updates
|
||||
TRACE_LEVEL_STATE, // also report state changes
|
||||
TRACE_LEVEL_DATA, // also report data exchanges
|
||||
|
@ -53,6 +53,9 @@
|
||||
#define TRACE(msg, mask, args...) \
|
||||
trace(TRACE_LEVEL, (mask), TRACE_SOURCE, ist(TRC_LOC), NULL, TRC_5ARGS(0,##args,0,0,0,0,0), ist(msg))
|
||||
|
||||
#define TRACE_ERROR(msg, mask, args...) \
|
||||
trace(TRACE_LEVEL_ERROR, (mask), TRACE_SOURCE, ist(TRC_LOC), NULL, TRC_5ARGS(0,##args,0,0,0,0,0), ist(msg))
|
||||
|
||||
#define TRACE_USER(msg, mask, args...) \
|
||||
trace(TRACE_LEVEL_USER, (mask), TRACE_SOURCE, ist(TRC_LOC), NULL, TRC_5ARGS(0,##args,0,0,0,0,0), ist(msg))
|
||||
|
||||
@ -79,6 +82,7 @@
|
||||
|
||||
#if defined(DEBUG_DEV) || defined(DEBUG_FULL)
|
||||
# define DBG_TRACE(msg, mask, args...) TRACE(msg, mask, ##args)
|
||||
# define DBG_TRACE_ERROR(msg, mask, args...) TRACE_ERROR(msg, mask, ##args)
|
||||
# define DBG_TRACE_USER(msg, mask, args...) TRACE_USER(msg, mask, ##args)
|
||||
# define DBG_TRACE_DATA(msg, mask, args...) TRACE_DATA(msg, mask, ##args)
|
||||
# define DBG_TRACE_PROTO(msg, mask, args...) TRACE_PROTO(msg, mask, ##args)
|
||||
@ -89,6 +93,7 @@
|
||||
# define DBG_TRACE_POINT(mask, args...) TRACE_POINT(mask, ##args)
|
||||
#else
|
||||
# define DBG_TRACE(msg, mask, args...) do { /* do nothing */ } while(0)
|
||||
# define DBG_TRACE_ERROR(msg, mask, args...) do { /* do nothing */ } while(0)
|
||||
# define DBG_TRACE_USER(msg, mask, args...) do { /* do nothing */ } while(0)
|
||||
# define DBG_TRACE_DATA(msg, mask, args...) do { /* do nothing */ } while(0)
|
||||
# define DBG_TRACE_PROTO(msg, mask, args...) do { /* do nothing */ } while(0)
|
||||
|
@ -408,7 +408,9 @@ static int cli_parse_trace(char **args, char *payload, struct appctx *appctx, vo
|
||||
|
||||
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 @@ static int cli_parse_trace(char **args, char *payload, struct appctx *appctx, vo
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user