diff options
author | Daniel Salzman <daniel.salzman@nic.cz> | 2024-10-02 14:14:29 +0200 |
---|---|---|
committer | Daniel Salzman <daniel.salzman@nic.cz> | 2024-10-11 19:34:12 +0200 |
commit | d5afefe73faaad795a629ddded67b959e08dc34c (patch) | |
tree | 97e8e89a7fcf43518a6b9fe98723321520163949 /src | |
parent | ctl: replace cmd_zone_ctl() with cmd_zone_filter_ctl() (diff) | |
download | knot-d5afefe73faaad795a629ddded67b959e08dc34c.tar.xz knot-d5afefe73faaad795a629ddded67b959e08dc34c.zip |
ctl: add flags and filters to command log if debug enabled
Diffstat (limited to 'src')
-rw-r--r-- | src/knot/ctl/process.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/knot/ctl/process.c b/src/knot/ctl/process.c index 9e6e0dfda..7c4fa0207 100644 --- a/src/knot/ctl/process.c +++ b/src/knot/ctl/process.c @@ -18,6 +18,7 @@ #include "knot/ctl/commands.h" #include "knot/ctl/process.h" #include "libknot/error.h" +#include "contrib/openbsd/strlcat.h" #include "contrib/string.h" int ctl_process(knot_ctl_t *ctl, server_t *server, int thread_idx, bool *exclusive) @@ -72,22 +73,35 @@ int ctl_process(knot_ctl_t *ctl, server_t *server, int thread_idx, bool *exclusi const char *cmd_name = args.data[KNOT_CTL_IDX_CMD]; const char *zone_name = args.data[KNOT_CTL_IDX_ZONE]; + const char *flags = args.data[KNOT_CTL_IDX_FLAGS]; + const char *filters = args.data[KNOT_CTL_IDX_FILTERS]; + + char buff[32]; + char extra[64] = { 0 }; + if (log_enabled_debug() && flags != NULL && strlen(flags) > 0) { + (void)snprintf(buff, sizeof(buff), ", flags '%s'", flags); + strlcat(extra, buff, sizeof(extra)); + } + if (log_enabled_debug() && filters != NULL && strlen(filters) > 0) { + (void)snprintf(buff, sizeof(buff), ", filters '%s'", filters); + strlcat(extra, buff, sizeof(extra)); + } ctl_cmd_t cmd = ctl_str_to_cmd(cmd_name); if (cmd == CTL_CONF_LIST) { - log_ctl_debug("control, received command '%s'", cmd_name); + log_ctl_debug("control, received command '%s'%s", cmd_name, extra); } else if (cmd != CTL_NONE) { if (zone_name != NULL) { log_ctl_zone_str_info(zone_name, - "control, received command '%s'", cmd_name); + "control, received command '%s'%s", cmd_name, extra); } else { - log_ctl_info("control, received command '%s'", cmd_name); + log_ctl_info("control, received command '%s'%s", cmd_name, extra); } } else if (cmd_name != NULL){ - log_ctl_debug("control, invalid command '%s'", cmd_name); + log_ctl_debug("control, invalid command '%s'%s", cmd_name, extra); continue; } else { - log_ctl_debug("control, empty command"); + log_ctl_debug("control, empty command%s", extra); continue; } |