static FILE* log_output;
static log_callback_t *log_callbacks = NULL;
static FILE* log_output;
static log_callback_t *log_callbacks = NULL;
static char *log_strings[5] =
{
static char *log_strings[5] =
{
if (debug_level >= LOG_DEBUG)
{
/* print with count and time information */
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);
}
else
fprintf(log_output, "%s %d %d %s:%d %s(): %s", log_strings[level+1], count, t, file, line, function, string);
}
else
int log_register_commands(struct command_context_s *cmd_ctx)
{
int log_register_commands(struct command_context_s *cmd_ctx)
{
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,
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,
+
+
+
+
+long long timeval_ms()
+{
+ struct timeval now;
+ long long t=0;
+ gettimeofday(&now, NULL);
+
+ t+=now.tv_usec/1000;
+ t+=now.tv_sec*1000;
+
+ return t;
+}
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);
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
{
typedef struct duration_s
{