Add a --debug flag for DEBUG builds
If you compile with: DEBUG=true rake build then all the commands get a --debug flag as an option which will make the server dump crazy amounts of data to stderr.
This commit is contained in:
21
src/util.c
21
src/util.c
@@ -10,6 +10,7 @@
|
||||
#include "util.h"
|
||||
|
||||
static pthread_t main_thread;
|
||||
static int global_debug;
|
||||
|
||||
void error_init()
|
||||
{
|
||||
@@ -59,3 +60,23 @@ void* xmalloc(size_t size)
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
void set_debug(int value) {
|
||||
global_debug = value;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
# include <sys/times.h>
|
||||
# include <stdarg.h>
|
||||
|
||||
void debug(const char *msg, ...) {
|
||||
va_list argp;
|
||||
|
||||
if ( global_debug ) {
|
||||
fprintf(stderr, "%08x %4d: ", (int) pthread_self(), (int) clock() );
|
||||
fprintf(stderr, msg, argp);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user