Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add a boolean to each node indicating whether it's an internal node or not to allow...
[simgrid.git] / src / xbt / log.c
index b532cb0..0ed94a9 100644 (file)
 #include "xbt/error.h"
 #include "xbt/dynar.h"
 
-
-/** \defgroup XBT_log Logging support.
- *  \brief A generic logging facility in the spirit of log4j
+/** \addtogroup XBT_log
  *
  *  This section describes the API to the log functions used 
  *  everywhere in this project.
      
-<h3>Overview</h3>
+\section log_overview Overview
      
 This is an adaptation of the log4c project, which is dead upstream, and
 which I was given the permission to fork under the LGPL licence by the
@@ -37,7 +35,7 @@ concepts work together to enable developers to log messages according to
 message type and priority, and to control at runtime how these messages are
 formatted and where they are reported.
 
-<h3>Category hierarchy</h3>
+\section log_cat Category hierarchy
 
 The first and foremost advantage of any logging API over plain printf()
 resides in its ability to disable certain log statements while allowing
@@ -71,7 +69,9 @@ definition.
 Typically, there will be a Category for each module and sub-module, so you
 can independently control logging for each module.
 
-<h3>Priority</h3>
+For a list of all existing categories, please refer to the \ref XBT_log_cats section.
+
+\section log_pri Priority
 
 A category may be assigned a threshold priorty. The set of priorites are
 defined by the \ref e_xbt_log_priority_t enum. All logging request under
@@ -110,7 +110,7 @@ equivalent to the shorter:
 
 <code>CWARN4(MyCat, "Values are: %d and '%s'", 5, "oops");</code>
 
-<h3>Default category</h3>
+\subsection log_subcat Using a default category
   
 If \ref XBT_LOG_NEW_DEFAULT_SUBCATEGORY(MyCat, Parent) or
 \ref XBT_LOG_NEW_DEFAULT_CATEGORY(MyCat) is used to create the
@@ -121,7 +121,7 @@ category, then the even shorter form can be used:
 Only one default category can be created per file, though multiple
 non-defaults can be created and used.
 
-<h3>Example</h3>
+\section log_example Example
 
 Here is a more complete example:
 
@@ -151,7 +151,7 @@ int main() {
 }
 \endverbatim
 
-<h3>Configuration</h3>
+\section log_conf Configuration
 Configuration is typically done during program initialization by invoking
 the xbt_log_control_set() method. The control string passed to it typically
 comes from the command line. Look at the documentation for that function for
@@ -162,7 +162,7 @@ Any SimGrid program can furthermore be configured at run time by passing a
 --surf-log are synonyms). You can provide several of those arguments to
 change the setting of several categories.
 
-<h3>Performance</h3>
+\section log_perf Performance
 
 Clever design insures efficiency. Except for the first invocation, a
 disabled logging request requires an a single comparison of a static
@@ -174,8 +174,12 @@ by the compiler. By setting it to gras_log_priority_infinite, all logging
 requests are statically disabled and cost nothing. Released executables
 might be compiled with
 \verbatim-DXBT_LOG_STATIC_THRESHOLD=gras_log_priority_infinite\endverbatim
-    
-<h3>Appenders</h3>
+
+Compiling with the \verbatim-DNLOG\endverbatim option disables all logging 
+requests at compilation time while the \verbatim-DNDEBUG\endverbatim disables 
+the requests of priority below INFO.
+\section log_app Appenders
 
 Each category has an optional appender. An appender is a pointer to a
 structure which starts with a pointer to a doAppend() function. DoAppend()
@@ -199,15 +203,13 @@ remote dedicated server, or other ones offering different output formats.
 This is on our TODO list for quite a while now, but your help would be
 welcome here.
 
-<h3>Misc and Caveats</h3>
-
-Do not use any of the macros that start with '_'.
-
-Log4J has a 'rolling file appender' which you can select with a run-time
-option and specify the max file size. This would be a nice default for
-non-kernel applications.
+\section log_misc Misc and Caveats
 
-Careful, category names are global variables.
+  - Do not use any of the macros that start with '_'.
+  - Log4J has a 'rolling file appender' which you can select with a run-time
+    option and specify the max file size. This would be a nice default for
+    non-kernel applications.
+  - Careful, category names are global variables.
 
 */
 
@@ -320,8 +322,8 @@ static xbt_dynar_t xbt_log_settings=NULL;
 static void _free_setting(void *s) {
   xbt_log_setting_t set=(xbt_log_setting_t)s;
   if (set) {
-    xbt_free(set->catname);
-/*    xbt_free(set); FIXME: uncommenting this leads to segfault when more than one chunk is passed as gras-log */
+    free(set->catname);
+/*    free(set); FIXME: uncommenting this leads to segfault when more than one chunk is passed as gras-log */
   }
 }
 
@@ -342,16 +344,17 @@ s_xbt_log_category_t _XBT_LOGV(XBT_LOG_ROOT_CAT) = {
   NULL, 0
 };
 
-XBT_LOG_NEW_SUBCATEGORY(xbt,XBT_LOG_ROOT_CAT,"All XBT categories (simgrid toolbox)");
-XBT_LOG_NEW_SUBCATEGORY(surf,XBT_LOG_ROOT_CAT,"All SURF categories");
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(log,xbt,"Loggings from the logging mecanism itself");
+XBT_LOG_NEW_CATEGORY(xbt,"All XBT categories (simgrid toolbox)");
+XBT_LOG_NEW_CATEGORY(surf,"All SURF categories");
+XBT_LOG_NEW_CATEGORY(msg,"All MSG categories");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(log,xbt,"Loggings from the logging mechanism itself");
 
 void xbt_log_init(int *argc,char **argv, const char *defaultlog) {
   int i,j;
   char *opt;
   int found=0;
 
-  /** Set logs and init log submodule */
+  /* Set logs and init log submodule */
   for (i=1; i<*argc; i++) {
     if (!strncmp(argv[i],"--gras-log=",strlen("--gras-log=")) ||
        !strncmp(argv[i],"--surf-log=",strlen("--surf-log=")) ||
@@ -557,7 +560,7 @@ static void _xbt_log_parse_setting(const char*        control_string,
     } else {
       xbt_assert1(FALSE,"Unknown priority name: %s",eq+1);
     }
-    xbt_free(neweq);
+    free(neweq);
   } else {
     char buff[512];
     snprintf(buff,min(512,eq - dot - 1),"%s",dot+1);
@@ -678,12 +681,12 @@ void xbt_log_control_set(const char* control_string) {
       set = xbt_new(s_xbt_log_setting_t,1);
     } else {
       DEBUG0("Apply directly");
-      xbt_free(set->catname);
+      free(set->catname);
       xbt_log_threshold_set(cat,set->thresh);
     }
   }
-  xbt_free(set);
-  xbt_free(cs);
+  free(set);
+  free(cs);
 } 
 
 void xbt_log_appender_set(xbt_log_category_t cat, xbt_log_appender_t app) {