From 10b7c79ad6ce754d044df091411b76b177b61ac2 Mon Sep 17 00:00:00 2001 From: mquinson Date: Tue, 7 Aug 2007 18:48:43 +0000 Subject: [PATCH] Use proper thread name, and some sanitizing of how we get the current time (using xbt portability layer, not the GRAS virtualization one) git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@4016 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- src/xbt/xbt_log_layout_format.c | 23 ++++++++++++++--------- src/xbt/xbt_log_layout_simple.c | 5 +++-- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/xbt/xbt_log_layout_format.c b/src/xbt/xbt_log_layout_format.c index 190d5dc4c9..2cf2a0f4b7 100644 --- a/src/xbt/xbt_log_layout_format.c +++ b/src/xbt/xbt_log_layout_format.c @@ -10,8 +10,9 @@ #include "portable.h" /* execinfo when available */ #include "xbt/sysdep.h" #include "xbt/log.h" -#include "gras/virtu.h" -#include "xbt/synchro.h" /* xbt_thread_self */ +#include "gras/virtu.h" /* gras_os_myname (KILLME) */ +#include "xbt/synchro.h" /* xbt_thread_self_name */ +#include "xbt/xbt_os_time.h" /* xbt_os_time */ #include extern const char *xbt_log_priority_names[7]; @@ -26,7 +27,7 @@ static char *xbt_log_layout_format_doit(xbt_log_layout_t l, int precision=-1; if (begin_of_time<0) - begin_of_time=gras_os_time(); + begin_of_time=xbt_os_time(); p = res; q = l->data; @@ -81,8 +82,12 @@ static char *xbt_log_layout_format_doit(xbt_log_layout_t l, } break; case 't': /* thread name; LOG4J compliant */ - p += sprintf(p, "%p", xbt_thread_self()); - precision = -1; + if (precision == -1) + p += sprintf(p, "%s", xbt_thread_self_name()); + else { + p += sprintf(p, "%.*s", precision, xbt_thread_self_name()); + precision = -1; + } break; case 'P': /* process name; SimGrid extension */ if (precision == -1) @@ -171,17 +176,17 @@ static char *xbt_log_layout_format_doit(xbt_log_layout_t l, case 'd': /* date; LOG4J compliant */ if (precision == -1) - p += sprintf(p,"%f", gras_os_time()); + p += sprintf(p,"%f", xbt_os_time()); else { - p += sprintf(p,"%.*f", precision, gras_os_time()); + p += sprintf(p,"%.*f", precision, xbt_os_time()); precision = -1; } break; case 'r': /* application age; LOG4J compliant */ if (precision == -1) - p += sprintf(p,"%f", gras_os_time()-begin_of_time); + p += sprintf(p,"%f", xbt_os_time()-begin_of_time); else { - p += sprintf(p,"%.*f", precision, gras_os_time()-begin_of_time); + p += sprintf(p,"%.*f", precision, xbt_os_time()-begin_of_time); precision = -1; } break; diff --git a/src/xbt/xbt_log_layout_simple.c b/src/xbt/xbt_log_layout_simple.c index 5933bf9ab0..adc5da593b 100644 --- a/src/xbt/xbt_log_layout_simple.c +++ b/src/xbt/xbt_log_layout_simple.c @@ -9,6 +9,7 @@ #include "xbt/sysdep.h" #include "xbt/log.h" +#include "xbt/synchro.h" /* xbt_thread_name */ #include "gras/virtu.h" #include @@ -35,8 +36,8 @@ static char *xbt_log_layout_simple_doit(xbt_log_layout_t l, p += sprintf(res,"[");; /* Display the proc info if available */ if(strlen(xbt_procname())) - p += sprintf(p,"%s:%s:(%d) ", - gras_os_myname(), xbt_procname(),(*xbt_getpid)()); + p += sprintf(p,"%s:%s:(%d):%s ", + gras_os_myname(), xbt_procname(),(*xbt_getpid)(),xbt_thread_self_name()); /* Display the date */ p += sprintf(p,"%f] ", gras_os_time()-begin_of_time); -- 2.20.1