diff options
-rw-r--r-- | include/openbsc/debug.h | 6 | ||||
-rw-r--r-- | src/debug.c | 18 |
2 files changed, 15 insertions, 9 deletions
diff --git a/include/openbsc/debug.h b/include/openbsc/debug.h index 56719806f..3945ee60c 100644 --- a/include/openbsc/debug.h +++ b/include/openbsc/debug.h @@ -15,15 +15,17 @@ #define DMIB 0x2000 #ifdef DEBUG -#define DEBUGP(ss, fmt, args...) debugp(ss, __FILE__, __LINE__, fmt, ## args) +#define DEBUGP(ss, fmt, args...) debugp(ss, __FILE__, __LINE__, 0, fmt, ## args) +#define DEBUGPC(ss, fmt, args...) debugp(ss, __FILE__, __LINE__, 1, fmt, ## args) #else #define DEBUGP(xss, fmt, args...) +#define DEBUGPC(ss, fmt, args...) #endif #define static_assert(exp, name) typedef int dummy##name [(exp) ? 1 : -1]; void hexdump(unsigned char *buf, int len); -void debugp(unsigned int subsys, char *file, int line, const char *format, ...); +void debugp(unsigned int subsys, char *file, int line, int cont, const char *format, ...); void debug_parse_category_mask(const char* mask); void debug_use_color(int use_color); unsigned int debug_mask; diff --git a/src/debug.c b/src/debug.c index 5504e112b..a3084e265 100644 --- a/src/debug.c +++ b/src/debug.c @@ -98,11 +98,9 @@ const char* color(int subsys) return ""; } -void debugp(unsigned int subsys, char *file, int line, const char *format, ...) +void debugp(unsigned int subsys, char *file, int line, int cont, const char *format, ...) { - char *timestr; va_list ap; - time_t tm; FILE *outfd = stderr; if (!(debug_mask & subsys)) @@ -110,10 +108,16 @@ void debugp(unsigned int subsys, char *file, int line, const char *format, ...) va_start(ap, format); - tm = time(NULL); - timestr = ctime(&tm); - timestr[strlen(timestr)-1] = '\0'; - fprintf(outfd, "%s%s <%4.4x> %s:%d ", color(subsys), timestr, subsys, file, line); + fprintf(outfd, "%s", color(subsys)); + + if (!cont) { + char *timestr; + time_t tm; + tm = time(NULL); + timestr = ctime(&tm); + timestr[strlen(timestr)-1] = '\0'; + fprintf(outfd, "%s <%4.4x> %s:%d ", timestr, subsys, file, line); + } vfprintf(outfd, format, ap); fprintf(outfd, "\033[0;m"); |