[PATCH] libcmpiutil, add time and thread info in CU_DEBUG

It seems libcmpiutil still uses HG, sorry I forgot how to send patch with HG, so paste the patch directly here and attach the patch generated from "hg export" as attachement. exporting patch: # HG changeset patch # User Wenchao Xia <xiawenc@linux.vnet.ibm.com> # Date 1351254054 -28800 # Node ID 4c82c8f418757be40bdd87575d309f17232545c0 # Parent 67a7b959ed47188efb8eb2f462bc7fc9ee145041 debug print, add time and thread info diff -r 67a7b959ed47 -r 4c82c8f41875 debug_util.c --- a/debug_util.c Fri Oct 26 17:22:29 2012 +0800 +++ b/debug_util.c Fri Oct 26 20:20:54 2012 +0800 @@ -23,7 +23,9 @@ #include <stdlib.h> #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 +34,15 @@ 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 +60,10 @@ log_init = 1; } - if (log != NULL) + if (log != NULL) { + 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); vfprintf(log, fmt, ap); + } va_end(ap); }
participants (1)
-
xiaxia347work