Mercurial > hg > freeDiameter
comparison include/freeDiameter/libfreeDiameter.h @ 205:ff9ade352076
Simplified use of --dbg_file option
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Fri, 12 Feb 2010 18:29:08 +0900 |
parents | de80f6a76c4f |
children | 8eda7c917fc6 |
comparison
equal
deleted
inserted
replaced
204:2465698b9f31 | 205:ff9ade352076 |
---|---|
68 #include <netdb.h> | 68 #include <netdb.h> |
69 #include <stdio.h> | 69 #include <stdio.h> |
70 #include <stdlib.h> | 70 #include <stdlib.h> |
71 #include <unistd.h> | 71 #include <unistd.h> |
72 | 72 |
73 #ifdef DEBUG | |
74 #include <libgen.h> /* for basename if --dbg_file is specified */ | |
75 #endif /* DEBUG */ | |
76 | |
73 /*============================================================*/ | 77 /*============================================================*/ |
74 /* DEBUG */ | 78 /* DEBUG */ |
75 /*============================================================*/ | 79 /*============================================================*/ |
76 #ifndef ASSERT | 80 #ifndef ASSERT |
77 #define ASSERT(x) assert(x) | 81 #define ASSERT(x) assert(x) |
164 #endif /* __STDC_VERSION__ < 199901L */ | 168 #endif /* __STDC_VERSION__ < 199901L */ |
165 #ifndef __PRETTY_FUNCTION__ | 169 #ifndef __PRETTY_FUNCTION__ |
166 #define __PRETTY_FUNCTION__ __func__ | 170 #define __PRETTY_FUNCTION__ __func__ |
167 #endif /* __PRETTY_FUNCTION__ */ | 171 #endif /* __PRETTY_FUNCTION__ */ |
168 | 172 |
173 /* A version of __FILE__ without the full path */ | |
174 static char * file_bname = NULL; | |
175 #define __STRIPPED_FILE__ (file_bname ?: (file_bname = basename(__FILE__))) | |
176 | |
169 /* Boolean for tracing at a certain level */ | 177 /* Boolean for tracing at a certain level */ |
178 #ifdef DEBUG | |
170 #define TRACE_BOOL(_level_) ( ((_level_) <= local_debug_level + fd_g_debug_lvl) \ | 179 #define TRACE_BOOL(_level_) ( ((_level_) <= local_debug_level + fd_g_debug_lvl) \ |
171 || (fd_debug_one_function && !strcmp(fd_debug_one_function, __PRETTY_FUNCTION__)) \ | 180 || (fd_debug_one_function && !strcmp(fd_debug_one_function, __PRETTY_FUNCTION__)) \ |
172 || (fd_debug_one_file && !strcmp(fd_debug_one_file, __FILE__) ) ) | 181 || (fd_debug_one_file && !strcmp(fd_debug_one_file, __STRIPPED_FILE__) ) ) |
182 #else /* DEBUG */ | |
183 #define TRACE_BOOL(_level_) ((_level_) <= local_debug_level + fd_g_debug_lvl) | |
184 #endif /* DEBUG */ | |
173 | 185 |
174 /* The general debug macro, each call results in two lines of debug messages (change the macro for more compact output) */ | 186 /* The general debug macro, each call results in two lines of debug messages (change the macro for more compact output) */ |
175 #define TRACE_DEBUG(level,format,args... ) { \ | 187 #define TRACE_DEBUG(level,format,args... ) { \ |
176 if ( TRACE_BOOL(level) ) { \ | 188 if ( TRACE_BOOL(level) ) { \ |
177 char __buf[25]; \ | 189 char __buf[25]; \ |