Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Connect categories before parsing the command line.
[simgrid.git] / src / xbt / log.c
index 8c78678..eb1f4f7 100644 (file)
@@ -647,9 +647,11 @@ static void xbt_log_connect_categories(void)
   XBT_LOG_CONNECT(msg_process, msg);
   XBT_LOG_CONNECT(msg_task, msg);
 
-  /* sd */
+  /* simdag */
   XBT_LOG_CONNECT(sd_daxparse, sd);
+#ifdef HAVE_GRAPHVIZ
   XBT_LOG_CONNECT(sd_dotparse, sd);
+#endif
   XBT_LOG_CONNECT(sd_kernel, sd);
   XBT_LOG_CONNECT(sd_task, sd);
   XBT_LOG_CONNECT(sd_workstation, sd);
@@ -702,17 +704,23 @@ 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;
 
   //    _XBT_LOGV(log).threshold = xbt_log_priority_debug; /* uncomment to set the LOG category to debug directly */
 
+  xbt_log_connect_categories();
+
   /* Set logs and init log submodule */
   for (j = i = 1; i < *argc; i++) {
     if (!strncmp(argv[i], "--log=", strlen("--log="))) {
@@ -720,6 +728,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];
     }
@@ -729,7 +741,13 @@ void xbt_log_init(int *argc, char **argv)
     *argc = j;
   }
 
-  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 +1282,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 +1376,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), "   ");