# HG changeset patch # User Sebastien Decugis # Date 1265180336 -32400 # Node ID 2b2f78036749b3373561c643a48631bc085b29c4 # Parent 4c0f358b89823d8e82a445b2d65832276c7435bc Added simple command-line switch to turn on full debug for specific function or file diff -r 4c0f358b8982 -r 2b2f78036749 freeDiameter/main.c --- a/freeDiameter/main.c Wed Feb 03 11:43:22 2010 +0900 +++ b/freeDiameter/main.c Wed Feb 03 15:58:56 2010 +0900 @@ -191,6 +191,8 @@ { "debug", no_argument, NULL, 'd' }, { "quiet", no_argument, NULL, 'q' }, { "dbglocale", optional_argument, NULL, 'l' }, + { "dbg_func", required_argument, NULL, 'f' }, + { "dbg_file", required_argument, NULL, 'F' }, { NULL, 0, NULL, 0 } }; @@ -230,6 +232,14 @@ fd_g_debug_lvl++; break; + case 'f': /* Full debug for the function with this name. */ + fd_debug_one_function = optarg; + break; + + case 'F': /* Full debug for the file with this name. */ + fd_debug_one_file = optarg; + break; + case 'q': /* Decrease verbosity then remove debug messages. */ fd_g_debug_lvl--; break; diff -r 4c0f358b8982 -r 2b2f78036749 include/freeDiameter/libfreeDiameter.h --- a/include/freeDiameter/libfreeDiameter.h Wed Feb 03 11:43:22 2010 +0900 +++ b/include/freeDiameter/libfreeDiameter.h Wed Feb 03 15:58:56 2010 +0900 @@ -97,6 +97,8 @@ */ void fd_log_debug ( char * format, ... ); extern pthread_mutex_t fd_log_lock; +extern char * fd_debug_one_function; +extern char * fd_debug_one_file; /* * FUNCTION: fd_log_threadname @@ -165,7 +167,9 @@ #endif /* __PRETTY_FUNCTION__ */ /* Boolean for tracing at a certain level */ -#define TRACE_BOOL(_level_) ( (_level_) <= local_debug_level + fd_g_debug_lvl ) +#define TRACE_BOOL(_level_) ( ((_level_) <= local_debug_level + fd_g_debug_lvl) \ + || (fd_debug_one_function && !strcmp(fd_debug_one_function, __PRETTY_FUNCTION__)) \ + || (fd_debug_one_file && !strcmp(fd_debug_one_file, __FILE__) ) ) /* The general debug macro, each call results in two lines of debug messages (change the macro for more compact output) */ #define TRACE_DEBUG(level,format,args... ) { \ diff -r 4c0f358b8982 -r 2b2f78036749 libfreeDiameter/log.c --- a/libfreeDiameter/log.c Wed Feb 03 11:43:22 2010 +0900 +++ b/libfreeDiameter/log.c Wed Feb 03 15:58:56 2010 +0900 @@ -41,6 +41,11 @@ pthread_key_t fd_log_thname; int fd_g_debug_lvl = 0; +/* These may be used to pass specific debug requests via the command-line parameters */ +char * fd_debug_one_function = NULL; +char * fd_debug_one_file = NULL; + + /* Log a debug message */ void fd_log_debug ( char * format, ... ) {