diff options
author | Russell Belfer <rb@github.com> | 2014-04-29 11:29:49 -0700 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2014-05-02 09:21:33 -0700 |
commit | b23b112dfe8eceb39eaaea2d5e60d971c4371aa0 (patch) | |
tree | 56a6c981856e5f1bf830c3b647a8a58838b044f5 /include/git2/trace.h | |
parent | 225aab5d6a611076b22f00ae5a28184d92b5259c (diff) | |
download | libgit2-b23b112dfe8eceb39eaaea2d5e60d971c4371aa0.tar.gz |
Add payloads, bitmaps to trace API
This is a proposed adjustment to the trace APIs. This makes the
trace levels into a bitmask so that they can be selectively enabled
and adds a callback-level payload, plus a message-level payload.
This makes it easier for me to a GIT_TRACE_PERF callbacks that
are simply bypassed if the PERF level is not set.
Diffstat (limited to 'include/git2/trace.h')
-rw-r--r-- | include/git2/trace.h | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/include/git2/trace.h b/include/git2/trace.h index f9b4d6ff6..867b34612 100644 --- a/include/git2/trace.h +++ b/include/git2/trace.h @@ -20,47 +20,64 @@ GIT_BEGIN_DECL /** - * Available tracing levels. When tracing is set to a particular level, - * callers will be provided tracing at the given level and all lower levels. + * Available tracing messages. Each tracing level can be enabled + * independently or pass GIT_TRACE_ALL to enable all levels. */ typedef enum { /** No tracing will be performed. */ - GIT_TRACE_NONE = 0, + GIT_TRACE_NONE = 0x0000u, + + /** All tracing messages will be sent. */ + GIT_TRACE_ALL = 0xFFFFu, /** Severe errors that may impact the program's execution */ - GIT_TRACE_FATAL = 1, + GIT_TRACE_FATAL = 0x0001u, /** Errors that do not impact the program's execution */ - GIT_TRACE_ERROR = 2, + GIT_TRACE_ERROR = 0x0002u, + GIT_TRACE_ERROR_AND_BELOW = 0x0003u, /** Warnings that suggest abnormal data */ - GIT_TRACE_WARN = 3, + GIT_TRACE_WARN = 0x0004u, + GIT_TRACE_WARN_AND_BELOW = 0x0007u, /** Informational messages about program execution */ - GIT_TRACE_INFO = 4, + GIT_TRACE_INFO = 0x0008u, + GIT_TRACE_INFO_AND_BELOW = 0x000Fu, /** Detailed data that allows for debugging */ - GIT_TRACE_DEBUG = 5, + GIT_TRACE_DEBUG = 0x0010u, /** Exceptionally detailed debugging data */ - GIT_TRACE_TRACE = 6 + GIT_TRACE_TRACE = 0x0020u, + + /** Performance tracking related traces */ + GIT_TRACE_PERF = 0x0040u, } git_trace_level_t; /** * An instance for a tracing function */ -typedef void (*git_trace_callback)(git_trace_level_t level, const char *msg); +typedef void (*git_trace_callback)( + git_trace_level_t level, /* just one bit will be sent */ + void *cb_payload, + void *msg_payload, + const char *msg); /** * Sets the system tracing configuration to the specified level with the * specified callback. When system events occur at a level equal to, or * lower than, the given level they will be reported to the given callback. * - * @param level Level to set tracing to - * @param cb Function to call with trace data + * @param level Bitmask of all enabled trace levels + * @param cb Function to call with trace messages + * @param cb_payload Payload to pass when callback is invoked * @return 0 or an error code */ -GIT_EXTERN(int) git_trace_set(git_trace_level_t level, git_trace_callback cb); +GIT_EXTERN(int) git_trace_set( + git_trace_level_t level, + git_trace_callback cb, + void *cb_payload); /** @} */ GIT_END_DECL |