
Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com> --- debug_util.c | 19 ++++++++++++++++++- 1 files changed, 18 insertions(+), 1 deletions(-) diff --git a/debug_util.c b/debug_util.c index 2912fb6..864a3f7 100644 --- a/debug_util.c +++ b/debug_util.c @@ -24,6 +24,9 @@ #include <stdarg.h> #include <stdio.h> +#include <pthread.h> +#include <sys/time.h> +#include <time.h> #include "libcmpiutil.h" static int log_init = 0; @@ -32,6 +35,15 @@ static FILE *log = NULL; void debug_print(char *fmt, ...) { char *log_file = NULL; + pthread_t id = pthread_self(); + struct timeval tv; + struct timezone tz; + gettimeofday(&tv, &tz); + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); + va_list ap; va_start(ap, fmt); @@ -49,8 +61,13 @@ void debug_print(char *fmt, ...) log_init = 1; } - if (log != NULL) + if (log != NULL) { vfprintf(log, fmt, ap); + fprintf(log, "time[%d-%02d-%02d %02d:%02d:%02d.%06d] " + "thread[%ld] ", + (1900+p->tm_year), (1+p->tm_mon), p->tm_mday, + p->tm_hour, p->tm_min, p->tm_sec, (int)tv.tv_usec, id); + } va_end(ap); } -- 1.7.1