X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/037955e458fb05c8ad1a1bdc3509bac0664f87a2..652f57a8ad22d3b0194df708c7049be37d7d3074:/src/xbt/xbt_log_layout_format.c diff --git a/src/xbt/xbt_log_layout_format.c b/src/xbt/xbt_log_layout_format.c index 27ac36bf64..2407d59cb9 100644 --- a/src/xbt/xbt_log_layout_format.c +++ b/src/xbt/xbt_log_layout_format.c @@ -10,17 +10,16 @@ #include "portable.h" /* execinfo when available */ #include "xbt/sysdep.h" #include "xbt/log.h" -#include "gras/virtu.h" +#include "gras/virtu.h" /* gras_os_myname (KILLME) */ +#include "xbt/synchro.h" /* xbt_thread_self_name */ #include -#include "xbt/ex_interface.h" /* backtraces */ extern const char *xbt_log_priority_names[7]; -static char *xbt_log_layout_format_doit(xbt_log_layout_t l, - xbt_log_event_t ev, - const char *msg_fmt) { - static char res[2048]; +static void xbt_log_layout_format_doit(xbt_log_layout_t l, + xbt_log_event_t ev, + const char *msg_fmt) { static double begin_of_time = -1; char *p,*q; int precision=-1; @@ -28,7 +27,7 @@ static char *xbt_log_layout_format_doit(xbt_log_layout_t l, if (begin_of_time<0) begin_of_time=gras_os_time(); - p = res; + p = ev->buffer; q = l->data; while (*q != '\0') { @@ -37,7 +36,8 @@ static char *xbt_log_layout_format_doit(xbt_log_layout_t l, handle_modifier: switch (*q) { case '\0': - THROW1(arg_error,0,"Layout format (%s) ending with %%",(char*)l->data); + fprintf(stderr,"Layout format (%s) ending with %%\n",(char*)l->data); + abort(); case '%': *p++ = '%'; break; @@ -79,7 +79,15 @@ static char *xbt_log_layout_format_doit(xbt_log_layout_t l, precision = -1; } break; - case 't': /* process name; LOG4J compliant (thread name) */ + case 't': /* thread name; LOG4J compliant */ + 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) p += sprintf(p, "%s", xbt_procname()); else { @@ -139,7 +147,7 @@ static char *xbt_log_layout_format_doit(xbt_log_layout_t l, e.bt_strings = NULL; e.msg=NULL; e.remote=0; - xbt_ex_setup_backtrace(&e); + xbt_backtrace_current(&e); if (*q=='B') { if (precision == -1) p += sprintf(p,"%s",e.bt_strings[2]+8); @@ -191,8 +199,9 @@ static char *xbt_log_layout_format_doit(xbt_log_layout_t l, break; default: - THROW2(arg_error,0,"Unknown %%%c sequence in layout format (%s)", - *q,(char*)l->data); + fprintf(stderr,"Unknown %%%c sequence in layout format (%s)\n", + *q,(char*)l->data); + abort(); } q++; } else { @@ -200,7 +209,6 @@ static char *xbt_log_layout_format_doit(xbt_log_layout_t l, } } *p = '\0'; - return res; } static void xbt_log_layout_format_free(xbt_log_layout_t lay) {