Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
proper xbt_log_init function
[simgrid.git] / src / xbt / module.c
index d435369..9dfed32 100644 (file)
@@ -2,11 +2,10 @@
 
 /* module handling                                                          */
 
-/* Authors: Martin Quinson                                                  */
-/* Copyright (C) 2003 the OURAGAN project.                                  */
+/* Copyright (c) 2004 Martin Quinson. All rights reserved.                  */
 
 /* This program is free software; you can redistribute it and/or modify it
  under the terms of the license (GNU LGPL) which comes with this package. */
* under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "xbt/sysdep.h"
 #include "xbt/log.h"
@@ -35,7 +34,10 @@ struct xbt_module_ {
 
 void 
 xbt_init(int *argc, char **argv) {
-   xbt_init_defaultlog(argc, argv, NULL);
+  static short int first_run = 1;
+  if(first_run)
+    xbt_init_defaultlog(argc, argv, NULL);
+  first_run = 0;
 }
 
 /**
@@ -47,32 +49,9 @@ xbt_init(int *argc, char **argv) {
  */
 void
 xbt_init_defaultlog(int *argc,char **argv, const char *defaultlog) {
-  int i,j;
-  char *opt;
-  int found=0;
-
   INFO0("Initialize GRAS");
   
-  /** Set logs and init log submodule */
-  for (i=1; i<*argc; i++) {
-    if (!strncmp(argv[i],"--gras-log=",strlen("--gras-log="))) {
-      found = 1;
-      opt=strchr(argv[i],'=');
-      opt++;
-      xbt_log_control_set(opt);
-      DEBUG1("Did apply '%s' as log setting",opt);
-      /*remove this from argv*/
-      for (j=i+1; j<*argc; j++) {
-       argv[j-1] = argv[j];
-      } 
-      argv[j-1] = NULL;
-      (*argc)--;
-      i--; /* compensate effect of next loop incrementation */
-    }
-  }
-  if (!found && defaultlog) {
-     xbt_log_control_set(defaultlog);
-  }
+  xbt_log_init(argc,argv,defaultlog);
    
   gras_process_init(); /* calls procdata_init, which calls dynar_new */
   /** init other submodules */