Log func also.

This commit is contained in:
Your Name
2026-06-30 09:39:34 +01:00
parent 45f4000017
commit b8a62979ac
2 changed files with 13 additions and 10 deletions

View File

@@ -831,34 +831,36 @@ cmd_parse_escape(const char *s)
}
static void
cmd_parse_log_one_node(struct cmd_parse_node *node, u_int depth)
cmd_parse_log_one_node(const char *prefix, struct cmd_parse_node *node,
u_int depth)
{
struct cmd_parse_node *child;
const char *type = cmd_parse_node_type_string(node->type);
char *escaped;
if (node->value == NULL)
log_debug("%*s%s", depth * 2, "", type);
log_debug("%s: %*s%s", prefix, depth * 2, "", type);
else {
escaped = cmd_parse_escape(node->value);
log_debug("%*s%s value=\"%s\"", depth * 2, "", type, escaped);
log_debug("%s: %*s%s value=\"%s\"", prefix, depth * 2, "",
type, escaped);
free(escaped);
}
TAILQ_FOREACH(child, &node->children, entry)
cmd_parse_log_one_node(child, depth + 1);
cmd_parse_log_one_node(prefix, child, depth + 1);
}
void
cmd_parse_log_node(struct cmd_parse_node *node)
cmd_parse_log_node(const char *prefix, struct cmd_parse_node *node)
{
cmd_parse_log_one_node(node, 0);
cmd_parse_log_one_node(prefix, node, 0);
}
void
cmd_parse_log(struct cmd_parse_tree *tree)
cmd_parse_log(const char *prefix, struct cmd_parse_tree *tree)
{
cmd_parse_log_node(tree->root);
cmd_parse_log_node(prefix, tree->root);
}
/* Does this literal text need quoting to reparse as itself? */

View File

@@ -81,8 +81,9 @@ struct cmd_parse_tree *cmd_parse_add_ref(struct cmd_parse_tree *);
void cmd_parse_free(struct cmd_parse_tree *);
struct cmd_parse_node *cmd_parse_root(struct cmd_parse_tree *);
char *cmd_parse_print(struct cmd_parse_tree *);
void cmd_parse_log(struct cmd_parse_tree *);
void cmd_parse_log_node(struct cmd_parse_node *);
void cmd_parse_log(const char *, struct cmd_parse_tree *);
void cmd_parse_log_node(const char *,
struct cmd_parse_node *);
enum cmd_parse_node_type cmd_parse_node_type(struct cmd_parse_node *);
const char *cmd_parse_node_type_string(enum cmd_parse_node_type);
const char *cmd_parse_node_value(struct cmd_parse_node *);