]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: trace: support a default callback for the source
authorWilly Tarreau <w@1wt.eu>
Wed, 28 Aug 2019 05:03:58 +0000 (07:03 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 28 Aug 2019 05:06:23 +0000 (07:06 +0200)
It becomes apparent that most traces will use a single trace pretty
print callback, so let's allow the trace source to declare a default
one so that it can be omitted from trace calls, and will be used if
no other one is specified.

include/types/trace.h
src/trace.c

index e43cb88b991051a56c8b4d5f3026579a1fbbfff0..152cc8ff6cdd986d67dc90b56e59f9127889d1bd 100644 (file)
@@ -129,6 +129,9 @@ struct trace_source {
        const char *desc;
        const struct trace_event *known_events;
        struct list source_link; // element in list of known trace sources
+       void (*default_cb)(enum trace_level level, uint64_t mask,
+                          const struct trace_source *src, const struct ist where,
+                          const void *a1, const void *a2, const void *a3, const void *a4);
        uint32_t arg_def;        // argument definitions (sum of TRC_ARG{1..4}_*)
        const struct trace_lockon_arg *lockon_args; // must be 4 entries if not NULL
        /* trace configuration, adjusted by "trace <module>" on CLI */
index 039bf3a706551b25a264dd04ea91135571400e46..e8de89bac518c8fe5b8550ffef8738d4cfd062e0 100644 (file)
@@ -184,6 +184,9 @@ void __trace(enum trace_level level, uint64_t mask, struct trace_source *src, co
        }
        line[2] = ist("] ");
 
+       if (!cb)
+               cb = src->default_cb;
+
        if (cb) {
                /* decode function passed, we want to pre-fill the
                 * buffer with the message and let the decode function