mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-08 11:53:00 -04:00
Merge branch '21_enable_debugging'
This commit is contained in:
commit
e20eabd69a
@ -640,6 +640,25 @@ typedef void (*event_fatal_cb)(int err);
|
||||
*/
|
||||
void event_set_fatal_callback(event_fatal_cb cb);
|
||||
|
||||
#define EVENT_DBG_ALL 0xffffffffu
|
||||
#define EVENT_DBG_NONE 0
|
||||
|
||||
/**
|
||||
Turn on debugging logs and have them sent to the default log handler.
|
||||
|
||||
This is a global setting; if you are going to call it, you must call this
|
||||
before any calls that create an event-base. You must call it before any
|
||||
multithreaded use of Libevent.
|
||||
|
||||
Debug logs are verbose.
|
||||
|
||||
@param which Controls which debug messages are turned on. This option is
|
||||
unused for now; for forward compatibility, you must pass in the constant
|
||||
"EVENT_DBG_ALL" to turn debugging logs on, or "EVENT_DBG_NONE" to turn
|
||||
debugging logs off.
|
||||
*/
|
||||
void event_enable_debug_logging(ev_uint32_t which);
|
||||
|
||||
/**
|
||||
Associate a different event base with an event.
|
||||
|
||||
|
@ -39,6 +39,23 @@
|
||||
|
||||
#define _EVENT_ERR_ABORT ((int)0xdeaddead)
|
||||
|
||||
#define USE_GLOBAL_FOR_DEBUG_LOGGING
|
||||
|
||||
#if !defined(_EVENT_DISABLE_DEBUG_MODE) || defined(USE_DEBUG)
|
||||
#define EVENT_DEBUG_LOGGING_ENABLED
|
||||
#endif
|
||||
|
||||
#ifdef EVENT_DEBUG_LOGGING_ENABLED
|
||||
#ifdef USE_GLOBAL_FOR_DEBUG_LOGGING
|
||||
extern ev_uint32_t _event_debug_logging_mask;
|
||||
#define _event_debug_get_logging_mask() (_event_debug_logging_mask)
|
||||
#else
|
||||
ev_uint32_t _event_debug_get_logging_mask(void);
|
||||
#endif
|
||||
#else
|
||||
#define _event_debug_get_logging_mask() (0)
|
||||
#endif
|
||||
|
||||
void event_err(int eval, const char *fmt, ...) EV_CHECK_FMT(2,3) EV_NORETURN;
|
||||
void event_warn(const char *fmt, ...) EV_CHECK_FMT(1,2);
|
||||
void event_sock_err(int eval, evutil_socket_t sock, const char *fmt, ...) EV_CHECK_FMT(3,4) EV_NORETURN;
|
||||
@ -48,10 +65,14 @@ void event_warnx(const char *fmt, ...) EV_CHECK_FMT(1,2);
|
||||
void event_msgx(const char *fmt, ...) EV_CHECK_FMT(1,2);
|
||||
void _event_debugx(const char *fmt, ...) EV_CHECK_FMT(1,2);
|
||||
|
||||
#ifdef USE_DEBUG
|
||||
#define event_debug(x) _event_debugx x
|
||||
#ifdef EVENT_DEBUG_LOGGING_ENABLED
|
||||
#define event_debug(x) do { \
|
||||
if (_event_debug_get_logging_mask()) { \
|
||||
_event_debugx x; \
|
||||
} \
|
||||
} while (0)
|
||||
#else
|
||||
#define event_debug(x) do {;} while (0)
|
||||
#define event_debug(x) ((void)0)
|
||||
#endif
|
||||
|
||||
#undef EV_CHECK_FMT
|
||||
|
19
log.c
19
log.c
@ -64,6 +64,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)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user