Commit a3dbb9ce authored by oharboe's avatar oharboe
Browse files

print ms in debug_level 3 logs. Seconds is not enough.

git-svn-id: svn:// b42882b7-edfa-0310-969c-e2dbd0fdcd60
parent b8dab6d0
......@@ -35,7 +35,7 @@ int debug_level = -1;
static FILE* log_output;
static log_callback_t *log_callbacks = NULL;
static time_t start;
static long long start;
static char *log_strings[5] =
......@@ -77,7 +77,7 @@ static void log_puts(enum log_levels level, const char *file, int line, const ch
if (debug_level >= LOG_DEBUG)
/* print with count and time information */
int t=(int)(time(NULL)-start);
int t=(int)(timeval_ms()-start);
fprintf(log_output, "%s %d %d %s:%d %s(): %s", log_strings[level+1], count, t, file, line, function, string);
......@@ -191,7 +191,7 @@ int handle_log_output_command(struct command_context_s *cmd_ctx, char *cmd, char
int log_register_commands(struct command_context_s *cmd_ctx)
start = time(NULL);
start = timeval_ms();
register_command(cmd_ctx, NULL, "log_output", handle_log_output_command,
COMMAND_ANY, "redirect logging to <file> (default: stderr)");
register_command(cmd_ctx, NULL, "debug_level", handle_debug_level_command,
......@@ -111,3 +111,18 @@ int duration_stop_measure(duration_t *duration, char **text)
return ERROR_OK;
long long timeval_ms()
struct timeval now;
long long t=0;
gettimeofday(&now, NULL);
return t;
......@@ -26,6 +26,8 @@
extern int timeval_subtract(struct timeval *result, struct timeval *x, struct timeval *y);
extern int timeval_add(struct timeval *result, struct timeval *x, struct timeval *y);
extern int timeval_add_time(struct timeval *result, int sec, int usec);
/* gettimeofday() timeval in 64 bit ms */
extern long long timeval_ms();
typedef struct duration_s
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment