]> git.ipfire.org Git - pakfire.git/commitdiff
parser: Make this less verbose
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 12 Oct 2024 14:25:54 +0000 (14:25 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 12 Oct 2024 14:25:54 +0000 (14:25 +0000)
The parser generates so much logging output that I cannot find anything
in the logs any more.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/parser.c

index 263001b7d693ec0d14f97d991bc620989d5d649b..b7a4a0cb4d80c6b46fa72973b603d7074eda8a68 100644 (file)
@@ -43,6 +43,9 @@
 #include <pakfire/string.h>
 #include <pakfire/util.h>
 
+// Enable to get more debugging output
+//#define PAKFIRE_DEBUG_PARSER
+
 struct pakfire_parser {
        struct pakfire_ctx* ctx;
        struct pakfire* pakfire;
@@ -180,10 +183,12 @@ static struct pakfire_parser_declaration* pakfire_parser_get_declaration(
        if (!namespace)
                namespace = "";
 
+#ifdef PAKFIRE_DEBUG_PARSER
        if (*namespace)
                DEBUG(parser->pakfire, "%p: Looking up %s.%s\n", parser, namespace, name);
        else
                DEBUG(parser->pakfire, "%p: Looking up %s\n", parser, name);
+#endif /* PAKFIRE_DEBUG_PARSER */
 
        struct pakfire_parser_declaration* d;
        for (unsigned i = 0; i < parser->num_declarations; i++) {
@@ -193,13 +198,17 @@ static struct pakfire_parser_declaration* pakfire_parser_get_declaration(
 
                // Return if namespace and name match
                if ((strcmp(d->namespace, namespace) == 0) && (strcmp(d->name, name) == 0)) {
+#ifdef PAKFIRE_DEBUG_PARSER
                        DEBUG(parser->pakfire, "%p: Found result = %s\n", parser, d->value);
+#endif /* PAKFIRE_DEBUG_PARSER */
 
                        return d;
                }
        }
 
+#ifdef PAKFIRE_DEBUG_PARSER
        DEBUG(parser->pakfire, "%p: Nothing found\n", parser);
+#endif /* PAKFIRE_DEBUG_PARSER */
 
        return NULL;
 }
@@ -458,7 +467,9 @@ static int pakfire_parser_expand_commands(struct pakfire_parser* parser, char**
                if (r)
                        goto ERROR;
 
+#ifdef PAKFIRE_DEBUG_PARSER
                DEBUG(parser->pakfire, "Expanding command: %s\n", command);
+#endif /* PAKFIRE_DEBUG_PARSER */
 
                // Update argv
                argv[2] = (const char*)command;
@@ -564,7 +575,9 @@ static int pakfire_parser_expand_variables(struct pakfire_parser* parser,
                if (r)
                        goto ERROR;
 
+#ifdef PAKFIRE_DEBUG_PARSER
                DEBUG(parser->pakfire, "Expanding variable: %s\n", variable);
+#endif /* PAKFIRE_DEBUG_PARSER */
 
                // Search for a declaration of this variable
                const char* repl = pakfire_parser_get_raw(parser, namespace, (const char*)variable);
@@ -586,12 +599,14 @@ static int pakfire_parser_expand_variables(struct pakfire_parser* parser,
                        }
                }
 
+#ifdef PAKFIRE_DEBUG_PARSER
                // What is its value?
                if (repl) {
                        DEBUG(parser->pakfire, "Replacing %%{%s} with '%s'\n", variable, repl);
                } else {
                        DEBUG(parser->pakfire, "Replacing %%{%s} with an empty string\n", variable);
                }
+#endif /* PAKFIRE_DEBUG_PARSER */
 
                // Replace all occurrences
                char* tmp = pakfire_string_replace(*buffer, (const char*)pattern, (repl) ? repl : "");