Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Handle --help-log* options from xbt_log_init.
authorArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Wed, 28 Mar 2012 19:30:02 +0000 (21:30 +0200)
committerArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Wed, 28 Mar 2012 19:55:09 +0000 (21:55 +0200)
include/xbt/log.h
src/surf/surf_config.c
src/xbt/log.c

index 7ff3646..53fef8c 100644 (file)
@@ -358,20 +358,6 @@ extern xbt_log_layout_t xbt_log_default_layout;
 /* Public functions again */
 /* ********************** */
 
-/**
- * \ingroup XBT_log
- *
- * Prints some help about using the logging infrastructure.
- */
-XBT_PUBLIC(void) xbt_log_help(void);
-
-/**
- * \ingroup XBT_log
- *
- * Prints the log category hierarchy.
- */
-XBT_PUBLIC(void) xbt_log_help_categories(void);
-
 /**
  * \ingroup XBT_log 
  * \param catName name of the category
index 816709c..7de2320 100644 (file)
@@ -63,12 +63,6 @@ static void surf_config_cmd_line(int *argc, char **argv)
                surf_optimization_mode_description[k].description);
       printf("Both network and CPU models have 'Lazy' as default optimization level\n\n");
       shall_exit = 1;
-    } else if (!strcmp(argv[i], "--help-logs")) {
-      xbt_log_help();
-      shall_exit = 1;
-    } else if (!strcmp(argv[i], "--help-log-categories")) {
-      xbt_log_help_categories();
-      shall_exit = 1;
 #ifdef HAVE_TRACING
     } else if (!strcmp(argv[i], "--help-tracing")) {
       TRACE_help (1);
index 8c78678..d3166af 100644 (file)
@@ -702,12 +702,16 @@ static void xbt_log_connect_categories(void)
 #endif /* simgrid_EXPORTS */
 }
 
+static void xbt_log_help(void);
+static void xbt_log_help_categories(void);
+
 /** @brief Get all logging settings from the command line
  *
  * xbt_log_control_set() is called on each string we got from cmd line
  */
 void xbt_log_init(int *argc, char **argv)
 {
+  unsigned help_requested = 0;  /* 1: logs; 2: categories */
   int i, j;
   char *opt;
 
@@ -720,6 +724,10 @@ void xbt_log_init(int *argc, char **argv)
       opt++;
       xbt_log_control_set(opt);
       XBT_DEBUG("Did apply '%s' as log setting", opt);
+    } else if (!strcmp(argv[i], "--help-logs")) {
+      help_requested |= 1;
+    } else if (!strcmp(argv[i], "--help-log-categories")) {
+      help_requested |= 2;
     } else {
       argv[j++] = argv[i];
     }
@@ -730,6 +738,14 @@ void xbt_log_init(int *argc, char **argv)
   }
 
   xbt_log_connect_categories();
+
+  if (help_requested) {
+    if (help_requested & 1)
+      xbt_log_help();
+    if (help_requested & 2)
+      xbt_log_help_categories();
+    exit(0);
+  }
 }
 
 static void log_cat_exit(xbt_log_category_t cat)
@@ -1264,7 +1280,7 @@ void xbt_log_additivity_set(xbt_log_category_t cat, int additivity)
   cat->additivity = additivity;
 }
 
-void xbt_log_help(void)
+static void xbt_log_help(void)
 {
   printf(
 "Description of the logging output:\n"
@@ -1358,7 +1374,7 @@ static void xbt_log_help_categories_rec(xbt_log_category_t category,
   xbt_free(child_prefix);
 }
 
-void xbt_log_help_categories(void)
+static void xbt_log_help_categories(void)
 {
   printf("Current log category hierarchy:\n");
   xbt_log_help_categories_rec(&_XBT_LOGV(XBT_LOG_ROOT_CAT), "   ");