Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
moved to %f instead of %g. It's usefull when values get large...
[simgrid.git] / src / xbt / log_default_appender.c
index 1bac48d..4094303 100644 (file)
@@ -9,8 +9,8 @@
 
 #include "xbt/sysdep.h"
 #include "xbt/log.h"
-#include "xbt/error.h"
 #include <stdio.h>
+#include "gras/virtu.h"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(log_app,log,"default logging handler");
 
@@ -35,6 +35,22 @@ static s_xbt_log_appender_t xbt_log_appender_file = { append_file, NULL } ;
 
 xbt_log_appender_t xbt_log_default_appender  = &xbt_log_appender_file;
 
+static const char* xbt_logappender_verbose_information(void) {
+  static char buffer[256];
+  static double begin_of_time = -1;
+  
+  if (begin_of_time<0) 
+    begin_of_time=gras_os_time();
+
+  if(strlen(xbt_procname()))
+    sprintf(buffer,"%s:%s:(%d) %f", gras_os_myname(),
+           xbt_procname(),gras_os_getpid(),gras_os_time()-begin_of_time);
+  else 
+    buffer[0]=0;
+  
+  return buffer;
+}
+
 static void append_file(xbt_log_appender_t this,
                        xbt_log_event_t ev, 
                        const char *fmt) {
@@ -42,7 +58,7 @@ static void append_file(xbt_log_appender_t this,
   /* TODO: define a format field in struct for timestamp, etc.
      struct DefaultLogAppender* this = (struct DefaultLogAppender*)this0;*/
 
-  char *procname = (char*)xbt_procname();
+  char *procname = (char*)xbt_logappender_verbose_information();
   if (!procname) 
      procname = (char*)"";