Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Stop build the log strings on the stack: we are multi-threaded now, and this is like...
[simgrid.git] / src / xbt / xbt_log_layout_format.c
index 2cf2a0f..2407d59 100644 (file)
 #include "xbt/log.h"
 #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 <stdio.h>
 
 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;
 
   if (begin_of_time<0) 
-    begin_of_time=xbt_os_time();
+    begin_of_time=gras_os_time();
 
-  p = res;
+  p = ev->buffer;
   q = l->data;
 
   while (*q != '\0') {
@@ -176,17 +174,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", xbt_os_time());
+          p += sprintf(p,"%f", gras_os_time());
         else {       
-          p += sprintf(p,"%.*f", precision, xbt_os_time());
+          p += sprintf(p,"%.*f", precision, gras_os_time());
           precision = -1;
        }        
        break;
       case 'r': /* application age; LOG4J compliant */
        if (precision == -1)
-          p += sprintf(p,"%f", xbt_os_time()-begin_of_time);
+          p += sprintf(p,"%f", gras_os_time()-begin_of_time);
         else {       
-          p += sprintf(p,"%.*f", precision, xbt_os_time()-begin_of_time);
+          p += sprintf(p,"%.*f", precision, gras_os_time()-begin_of_time);
           precision = -1;
        }        
        break;
@@ -211,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) {