summaryrefslogtreecommitdiff
path: root/log.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2010-12-16 13:58:56 -0500
committerNick Mathewson <nickm@torproject.org>2010-12-16 13:58:56 -0500
commite30a82f11829e3dc2cf1add253c768fa144db494 (patch)
tree27fc34bba15b8e56b1ef685f8f5d29abdb9ee25c /log.c
parentb8b8aa560c038c6f0c22a574d99d314a1f4a3b7a (diff)
downloadlibevent-e30a82f11829e3dc2cf1add253c768fa144db494.tar.gz
Add event_enable_debug_logging() to control use of debug logs
Previously, debug logs were turned on if you built with -DUSE_DEBUG and off otherwise. This make builds with -DUSE_DEBUG hideously slow and other builds unable to get debug logs. This is based off a patch by Ralph Castain from October. It tries a little harder to avoid needless function calls, it doesn't require stdbool, and makes the controlling parameter a mask rather than a boolean so that we can later support enabling only the debugging messages for the parts of Libevent you're trying to debug.
Diffstat (limited to 'log.c')
-rw-r--r--log.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/log.c b/log.c
index f0cd4320..79eaae71 100644
--- a/log.c
+++ b/log.c
@@ -63,6 +63,25 @@ static void event_exit(int errcode) EV_NORETURN;
static event_fatal_cb fatal_fn = NULL;
+#ifdef EVENT_DEBUG_LOGGING_ENABLED
+#ifdef USE_DEBUG
+#define DEFAULT_MASK EVENT_DBG_ALL
+#else
+#define DEFAULT_MASK 0
+#endif
+
+#ifdef USE_GLOBAL_FOR_DEBUG_LOGGING
+ev_uint32_t _event_debug_logging_mask = DEFAULT_MASK;
+#else
+static ev_uint32_t _event_debug_logging_mask = DEFAULT_MASK;
+ev_uint32_t
+_event_debug_get_logging_mask(void)
+{
+ return _event_debug_logging_mask;
+}
+#endif
+#endif /* EVENT_DEBUG_LOGGING_ENABLED */
+
void
event_set_fatal_callback(event_fatal_cb cb)
{