Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Increase debug message timestamp resolution to include usecs.
From a debugging standpoint you need much higher resolution then the
existing second granularity in the debug messages. This adds the usecs
to the debug message so we have the wanted granularity.
  • Loading branch information
Marco van Wieringen committed May 9, 2015
1 parent 093b229 commit 9d89f10
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/lib/message.c
Expand Up @@ -1191,7 +1191,9 @@ void d_msg(const char *file, int line, int level, const char *fmt,...)
int len;
va_list arg_ptr;
bool details = true;
utime_t mtime;
char ed1[50];
btime_t mtime;
uint32_t usecs;

if (level < 0) {
details = false;
Expand All @@ -1200,8 +1202,9 @@ void d_msg(const char *file, int line, int level, const char *fmt,...)

if (level <= debug_level) {
if (dbg_timestamp) {
mtime = time(NULL);
bstrftimes(buf, sizeof(buf), mtime);
mtime = get_current_btime();
usecs = mtime % 1000000;
bsnprintf(buf, sizeof(buf), "%s.%06d ", bstrftimes(ed1, sizeof(ed1), btime_to_utime(mtime)), usecs);
len = strlen(buf);
buf[len++] = ' ';
buf[len] = 0;
Expand Down

0 comments on commit 9d89f10

Please sign in to comment.