]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: trace: make trace() now also take a level in argument
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)
This new "level" argument will allow the trace sources to label the
traces for different purposes, and filter out some of them if they
are not relevant to the current target. Right now we have 5 different
levels:
  - USER : the least verbose one, only a few functional information
  - PAYLOAD: like user but also displays some payload-related information
  - PROTO: focuses on the protocol's framing
  - STATE: also indicate state internal transitions or non-transitions
  - DEVELOPER: adds extra info about branches taken in the code (break
    points, return points)

include/proto/trace.h
src/trace.c

index 7673892e893d609c4a396b68c85a6d7036873a9e..7875d149145b4763c4662f66816fa7bc96329f0a 100644 (file)
@@ -34,7 +34,7 @@
 extern struct list trace_sources;
 extern THREAD_LOCAL struct buffer trace_buf;
 
-void __trace(uint64_t mask, struct trace_source *src, const struct ist where, const struct ist msg);
+void __trace(enum trace_level level, uint64_t mask, struct trace_source *src, const struct ist where, const struct ist msg);
 
 /* return a single char to describe a trace state */
 static inline char trace_state_char(enum trace_state st)
@@ -66,10 +66,10 @@ static inline void trace_register_source(struct trace_source *source)
 }
 
 /* sends a trace for the given source */
-static inline void trace(uint64_t mask, struct trace_source *src, const struct ist where, const struct ist msg)
+static inline void trace(enum trace_level level, uint64_t mask, struct trace_source *src, const struct ist where, const struct ist msg)
 {
        if (unlikely(src->state != TRACE_STATE_STOPPED))
-               __trace(mask, src, where, msg);
+               __trace(level, mask, src, where, msg);
 }
 
 #endif /* _PROTO_TRACE_H */
index f68ff105823c1be705dc56bed5cd8c6c3a7b61ec..03656ff19b30a5b8a970f515baed6a59f0fe53b0 100644 (file)
@@ -49,7 +49,7 @@ REGISTER_PER_THREAD_ALLOC(alloc_trace_buffers_per_thread);
 REGISTER_PER_THREAD_FREE(free_trace_buffers_per_thread);
 
 /* write a message for the given trace source */
-void __trace(uint64_t mask, struct trace_source *src, const struct ist where, const struct ist msg)
+void __trace(enum trace_level level, uint64_t mask, struct trace_source *src, const struct ist where, const struct ist msg)
 {
        struct ist line[8];
 
@@ -74,7 +74,7 @@ void __trace(uint64_t mask, struct trace_source *src, const struct ist where, co
        /* TODO: add check of lockon+lockon_ptr here, return if no match */
        /* here the trace is running and is tracking a desired item */
 
-       if ((src->report_events & mask) == 0)
+       if ((src->report_events & mask) == 0 || level > src->level)
                goto end;
 
        /* log the logging location truncated to 10 chars from the right so that