src/log.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
New commits: commit 4ee0b253e6b5ccba730def74e3864f528678a663 Author: Federico Simoncelli fsimonce@redhat.com Date: Wed May 23 13:27:24 2012 +0000
log: add the thread id in the log messages
Signed-off-by: Federico Simoncelli fsimonce@redhat.com
diff --git a/src/log.c b/src/log.c index 614a855..fc516bc 100644 --- a/src/log.c +++ b/src/log.c @@ -21,6 +21,8 @@ #include <pthread.h> #include <sys/socket.h> #include <sys/time.h> +#include <sys/syscall.h> +#include <sys/types.h> #include <stdarg.h>
#include "sanlock_internal.h" @@ -120,6 +122,7 @@ void log_level(uint32_t space_id, uint32_t token_id, char *name_in, int level, c int len = LOG_STR_LEN - 2; /* leave room for \n\0 */ struct timeval cur_time; struct tm time_info; + pid_t tid;
memset(name, 0, sizeof(name));
@@ -137,11 +140,13 @@ void log_level(uint32_t space_id, uint32_t token_id, char *name_in, int level, c gettimeofday(&cur_time, NULL); localtime_r(&cur_time.tv_sec, &time_info); ret = strftime(log_str + pos, len - pos, - "%Y-%m-%d %H:%M:%S%z: ", &time_info); + "%Y-%m-%d %H:%M:%S%z ", &time_info); pos += ret;
- ret = snprintf(log_str + pos, len - pos, "%llu %s", - (unsigned long long)monotime(), name); + tid = syscall(SYS_gettid); + + ret = snprintf(log_str + pos, len - pos, "%llu [%u]: %s", + (unsigned long long) monotime(), tid, name); pos += ret;
va_start(ap, fmt);
sanlock-devel@lists.fedorahosted.org