Standardized format for debugging output, after a few trials
authoraland <aland>
Thu, 3 May 2007 09:03:16 +0000 (09:03 +0000)
committeraland <aland>
Thu, 3 May 2007 09:03:16 +0000 (09:03 +0000)
of different methods.  The new output is cleaner, less noisy,
and it's more obvious what's going on.

src/main/conffile.c
src/main/modules.c
src/modules/rlm_eap/eap.c

index 5d6ff1b..0e3e49b 100644 (file)
@@ -73,6 +73,7 @@ struct conf_part {
        rbtree_t        *name2_tree; /* for sections of the same name2 */
        rbtree_t        *data_tree;
        void            *base;
+       int depth;
        const CONF_PARSER *variables;
 };
 
@@ -415,6 +416,9 @@ static CONF_SECTION *cf_section_alloc(const char *name1, const char *name2,
         *      Don't create the section tree here, it may not
         *      be needed.
         */
+
+       if (parent) cs->depth = parent->depth + 1;
+
        return cs;
 }
 
@@ -881,6 +885,8 @@ int cf_item_parse(CONF_SECTION *cs, const char *name,
        return rcode;
 }
 
+static const char *parse_spaces = "                                                                                                                                                                                                                                                                ";
+
 /*
  *     Parse a configuration section into user-supplied variables.
  */
@@ -891,9 +897,11 @@ int cf_section_parse(CONF_SECTION *cs, void *base,
        void *data;
 
        if (!cs->name2) {
-               DEBUG2(" %s {", cs->name1);
+               DEBUG2("%.*s%s {", cs->depth, parse_spaces,
+                      cs->name1);
        } else {
-               DEBUG2(" %s %s {", cs->name1, cs->name2);
+               DEBUG2("%.*s%s %s {", cs->depth, parse_spaces,
+                      cs->name1, cs->name2);
        }
 
        /*
@@ -918,16 +926,12 @@ int cf_section_parse(CONF_SECTION *cs, void *base,
 
                        if (!variables[i].dflt) {
                                DEBUG2("Internal sanity check 1 failed in cf_section_parse");
-                               cf_section_parse_free(base, variables);
-                               DEBUG2(" }");
-                               return -1;
+                               goto error;
                        }
                        
                        if (cf_section_parse(subcs, base,
                                             (const CONF_PARSER *) variables[i].dflt) < 0) {
-                               cf_section_parse_free(base, variables);
-                               DEBUG2(" }");
-                               return -1;
+                               goto error;
                        }
                        continue;
                } /* else it's a CONF_PAIR */
@@ -938,9 +942,7 @@ int cf_section_parse(CONF_SECTION *cs, void *base,
                        data = ((char *)base) + variables[i].offset;
                } else {
                        DEBUG2("Internal sanity check 2 failed in cf_section_parse");
-                       cf_section_parse_free(base, variables);
-                       DEBUG2(" }");
-                       return -1;
+                       goto error;
                }
 
                /*
@@ -948,18 +950,21 @@ int cf_section_parse(CONF_SECTION *cs, void *base,
                 */
                if (cf_item_parse(cs, variables[i].name, variables[i].type,
                                  data, variables[i].dflt) < 0) {
-                       cf_section_parse_free(base, variables);
-                       DEBUG2(" }");
-                       return -1;
+                       goto error;
                }
        } /* for all variables in the configuration section */
 
-       DEBUG2(" }");
+       DEBUG2("%.*s}", cs->depth, parse_spaces);
 
        cs->base = base;
        cs->variables = variables;
 
        return 0;
+
+ error:
+       DEBUG2("%.*s}", cs->depth, parse_spaces);
+       cf_section_parse_free(base, variables);
+       return -1;
 }
 
 
index f4cf917..eff51d6 100644 (file)
@@ -228,7 +228,7 @@ static module_entry_t *linkto_module(const char *module_name,
        node->module = module;
        node->handle = handle;
 
-       DEBUG("Module: Linked to module %s", module_name);
+       DEBUG(" Module: Linked to module %s", module_name);
 
        /*
         *      Add the module as "rlm_foo-version" to the configuration
@@ -301,7 +301,7 @@ module_instance_t *find_module_instance(CONF_SECTION *modules,
                return NULL;
        }
 
-       DEBUG2("Module: Instantiating %s", instname);
+       DEBUG2(" Module: Instantiating %s", instname);
 
        /*
         *      Call the module's instantiation routine.
@@ -659,8 +659,8 @@ int setup_modules(int reload)
                 */
                lt_dlsetsearchpath(radlib_dir);
 
-               DEBUG2("Module: Library search path is %s",
-                               lt_dlgetsearchpath());
+               DEBUG2("radiusd: Library search path is %s",
+                      lt_dlgetsearchpath());
 
                /*
                 *      Set up the internal module struct.
@@ -887,6 +887,8 @@ int setup_modules(int reload)
                module_instance_t *module;
                const char *name;
 
+               DEBUG2(" instantiate {");
+
                /*
                 *  Loop over the items in the 'instantiate' section.
                 */
@@ -909,8 +911,12 @@ int setup_modules(int reload)
                                return -1;
                        }
                } /* loop over items in the subsection */
+
+               DEBUG2(" }");
        } /* if there's an 'instantiate' section. */
 
+       DEBUG2(" modules {");
+
        /*
         *      Loop over all of the known components, finding their
         *      configuration section, and loading it.
@@ -924,11 +930,19 @@ int setup_modules(int reload)
                        continue;
                }
 
+               if (cf_item_find_next(cs, NULL) == NULL) {
+                       continue; /* section is empty */
+               }
+               
+               DEBUG2(" Module: Instantiating section %s", section_type_value[comp].section);
+
                if (load_component_section(NULL, cs, comp, mainconfig.radiusd_conf) < 0) {
                        return -1;
                }
        }
 
+       DEBUG2(" }");
+
        return 0;
 }
 
index 06689f1..ff26c8f 100644 (file)
@@ -120,9 +120,9 @@ int eaptype_load(EAP_TYPES **type, int eap_type, CONF_SECTION *cs)
                free(node);
                return -1;
        }
-       DEBUG("eap: Linked to sub-module %s", buffer);
+       DEBUG("  eap: Linked to sub-module %s", buffer);
 
-       DEBUG("eap: Instantiating eap-%s", eaptype_name);
+       DEBUG("  eap: Instantiating eap-%s", eaptype_name);
 
        if ((node->type->attach) &&
            ((node->type->attach)(node->cs, &(node->type_data)) < 0)) {