don't prefix every line with timestamp, this saves some screen real estate

This commit is contained in:
Harald Welte 2009-06-09 20:21:57 +00:00
parent bd8f7e399b
commit d3ff51dfe3
3 changed files with 23 additions and 7 deletions

View File

@ -33,6 +33,7 @@ char *hexdump(unsigned char *buf, int len);
void debugp(unsigned int subsys, char *file, int line, int cont, 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_parse_category_mask(const char* mask);
void debug_use_color(int use_color); void debug_use_color(int use_color);
void debug_timestamp(int enable);
extern unsigned int debug_mask; extern unsigned int debug_mask;
#endif /* _DEBUG_H */ #endif /* _DEBUG_H */

View File

@ -1059,10 +1059,11 @@ static void handle_options(int argc, char** argv)
{"bts-type", 1, 0, 't'}, {"bts-type", 1, 0, 't'},
{"cardnr", 1, 0, 'C'}, {"cardnr", 1, 0, 'C'},
{"release-l2", 0, 0, 'R'}, {"release-l2", 0, 0, 'R'},
{"timestamp", 0, 0, 'T'},
{0, 0, 0, 0} {0, 0, 0, 0}
}; };
c = getopt_long(argc, argv, "hc:n:d:sar:p:f:t:C:RL:l:", c = getopt_long(argc, argv, "hc:n:d:sar:p:f:t:C:RL:l:T",
long_options, &option_index); long_options, &option_index);
if (c == -1) if (c == -1)
break; break;
@ -1111,6 +1112,9 @@ static void handle_options(int argc, char** argv)
case 'R': case 'R':
release_l2 = 1; release_l2 = 1;
break; break;
case 'T':
debug_timestamp(1);
break;
default: default:
/* ignore */ /* ignore */
break; break;

View File

@ -65,6 +65,14 @@ void debug_use_color(int color)
use_color = color; use_color = color;
} }
static int print_timestamp = 0;
void debug_timestamp(int enable)
{
print_timestamp = enable;
}
/* /*
* Parse the category mask. * Parse the category mask.
* category1:category2:category3 * category1:category2:category3
@ -114,12 +122,15 @@ void debugp(unsigned int subsys, char *file, int line, int cont, const char *for
fprintf(outfd, "%s", color(subsys)); fprintf(outfd, "%s", color(subsys));
if (!cont) { if (!cont) {
char *timestr; if (print_timestamp) {
time_t tm; char *timestr;
tm = time(NULL); time_t tm;
timestr = ctime(&tm); tm = time(NULL);
timestr[strlen(timestr)-1] = '\0'; timestr = ctime(&tm);
fprintf(outfd, "%s <%4.4x> %s:%d ", timestr, subsys, file, line); timestr[strlen(timestr)-1] = '\0';
fprintf(outfd, "%s ", timestr);
}
fprintf(outfd, "<%4.4x> %s:%d ", subsys, file, line);
} }
vfprintf(outfd, format, ap); vfprintf(outfd, format, ap);
fprintf(outfd, "\033[0;m"); fprintf(outfd, "\033[0;m");