1
#ifndef NDBMEMCACHE_DEBUG_H
2
#define NDBMEMCACHE_DEBUG_H
5
/* DEBUG macros for NDB Memcache.
7
Debugging is activated by defining DEBUG_OUTPUT at compile-time.
9
In order to use the THREAD_ variants of these macros, the caller must define
10
two macros, DEBUG_THD_ID and DEBUG_THD_NAME, in the source file.
11
DEBUG_THD_ID : (int) numeric thread id
12
DEBUG_THD_NAME : (const char *) thread name.
14
DEBUG_INIT(const char * outfile)
15
Initialize debugging. If outfile is null, STDERR will be used.
18
An assertion that is compiled only if debugging is enabled.
20
DEBUG_PRINT(), THREAD_DEBUG_PRINT():
21
These take printf() style parameter lists.
23
DEBUG_ENTER(), THREAD_DEBUG_ENTER:
24
Print the name of the function being entered.
26
ODD_DEBUG_ENTER(thread_id, thread_name, function_name)
27
ODD_DEBUG_PRINT(thread_id, thread_name, fmt, ... ):
28
Manual variants which allow the caller to specify the thread name and id.
32
#include "dbmemcache_global.h"
39
/* There's no if(do_debug) check on DEBUG_INIT or DEBUG_ASSERT */
40
#define DEBUG_INIT(OUTFILE, LEVEL) ndbmc_debug_init(OUTFILE, LEVEL)
41
#define DEBUG_ASSERT(X) assert(X)
43
#define DEBUG_PRINT(...) if(do_debug) ndbmc_debug_print(0, 0, __func__, __VA_ARGS__)
44
#define THREAD_DEBUG_PRINT(...) if(do_debug) ndbmc_debug_print(DEBUG_THD_ID, DEBUG_THD_NAME, __func__, __VA_ARGS__)
46
#define DEBUG_ENTER() if(do_debug) ndbmc_debug_enter(0, 0, __func__)
47
#define THREAD_DEBUG_ENTER() if(do_debug) ndbmc_debug_enter(DEBUG_THD_ID, DEBUG_THD_NAME, __func__)
49
#define ODD_DEBUG_ENTER(id, name, func) if(do_debug) ndbmc_debug_enter(id, name, func)
50
#define ODD_DEBUG_PRINT(id, name, ...) if(do_debug) ndbmc_debug_print(id, name, __func__, __VA_ARGS__)
53
#define DEBUG_INIT(...)
54
#define DEBUG_ASSERT(...)
55
#define DEBUG_PRINT(...)
56
#define THREAD_DEBUG_PRINT(...)
58
#define THREAD_DEBUG_ENTER()
59
#define ODD_DEBUG_ENTER(...)
60
#define ODD_DEBUG_PRINT(...)
64
/* internal prototypes for debug functions */
65
DECLARE_FUNCTIONS_WITH_C_LINKAGE
66
void ndbmc_debug_init(const char *file, bool enable);
67
void ndbmc_debug_print(int, const char *, const char *, const char *, ...);
68
void ndbmc_debug_enter(int, const char *, const char *);
69
END_FUNCTIONS_WITH_C_LINKAGE