]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Add debug/trace/tags information to .status header
authorEric Bollengier <eric@baculasystems.com>
Wed, 4 Aug 2021 14:24:18 +0000 (16:24 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 24 Mar 2022 08:03:03 +0000 (09:03 +0100)
bacula/src/dird/ua_status.c
bacula/src/filed/status.c
bacula/src/lib/message.c
bacula/src/lib/message.h
bacula/src/stored/status.c

index ac351f9bbcfb942e7428ec1450913b9e1d4d5f46..68cdb20677481437ca2374bc44a2363efc715f82 100644 (file)
@@ -436,6 +436,7 @@ static void do_all_status(UAContext *ua)
 
 static void api_list_dir_status_header(UAContext *ua)
 {
+   alist tlist(10, not_owned_by_alist);
    OutputWriter wt(ua->api_opts);
    wt.start_group("header");
    wt.get_output(
@@ -456,6 +457,9 @@ static void api_list_dir_status_header(UAContext *ua)
       OT_PLUGINS,"plugins",     b_plugin_list,
       OT_INT32,  "fips",        crypto_get_fips(),
       OT_STRING, "crypto",      crypto_get_version(),
+      OT_INT64,  "debug",       debug_level,
+      OT_INT,    "trace",       get_trace(),
+      OT_ALIST_STR, "tags",     debug_get_tags_list(&tlist, debug_level_tags),
       OT_END);
 
    ua->send_msg("%s", wt.end_group());
index 8a761594e36208c1d00143fba489ab8079d5cc9d..9df408bab8ae51918847651c894614b6cf2b051b 100644 (file)
@@ -79,6 +79,7 @@ static void api_list_status_header(STATUS_PKT *sp)
    char *p;
    char buf[300];
    const char *cipher=NULL, *digest=NULL;
+   alist tlist(10, not_owned_by_alist);
    OutputWriter wt(sp->api_opts);
    *buf = 0;
 
@@ -115,6 +116,7 @@ static void api_list_status_header(STATUS_PKT *sp)
       OT_STRING, "winver",      buf,
       OT_INT64,  "debug",       debug_level,
       OT_INT,    "trace",       get_trace(),
+      OT_ALIST_STR, "tags",     debug_get_tags_list(&tlist, debug_level_tags),
       OT_INT64,  "bwlimit",     me->max_bandwidth_per_job,
       OT_PLUGINS, "plugins",    b_plugin_list,
       OT_INT,     "pkiencryption", (int)me->pki_encrypt,
index 309d2605389a81e449165f58133fb0103644aeaa..4de6105900f89de033eb918b8866d6a44dd5a49b 100644 (file)
@@ -2031,6 +2031,35 @@ bool debug_find_tag(const char *tagname, bool add, int64_t *current_level)
    return false;
 }
 
+/* Convert back tag bits to a string */
+char *debug_get_tags(POOLMEM **options, int64_t current_level)
+{
+   bool first=true;
+
+   pm_strcpy(options, "");
+   for (int i = 0; debug_tags[i].tag; i++) {
+      if ((debug_tags[i].bit & current_level) == debug_tags[i].bit) {
+         if (!first) {
+            pm_strcat(options, ",");
+         }
+         pm_strcat(options, debug_tags[i].tag);
+         first=false;
+      }
+   }
+   return *options;
+}
+
+/* Convert back tag bits to a list (not_owned_by_alist) */
+alist *debug_get_tags_list(alist *options, int64_t current_level)
+{
+   for (int i = 0; debug_tags[i].tag; i++) {
+      if ((debug_tags[i].bit & current_level) == debug_tags[i].bit) {
+         options->append((char *)debug_tags[i].tag);
+      }
+   }
+   return options;
+}
+
 bool debug_parse_tags(const char *options, int64_t *current_level)
 {
    bool operation;              /* + => true, - false */
index bc647ac5c1971085c9ef3eaa1088de49afab37d9..38dbb990b95a533940189a398a8cdffbe0461815 100644 (file)
@@ -183,6 +183,8 @@ const char conn_info_wo_name[] = "Connected to %s at %s:%d %s\n";
 const char *debug_get_tag(uint32_t pos, const char **desc);
 bool debug_find_tag(const char *tagname, bool add, int64_t *current_level);
 bool debug_parse_tags(const char *options, int64_t *current_level);
+alist *debug_get_tags_list(alist *options, int64_t current_level);
+char *debug_get_tags(POOLMEM **options, int64_t current_level);
 
 class MSGS;
 MSGS *get_current_MSGS(JCR *jcr);
index a8cf658a35201ea7fbf0c1a7b17b1a5b4d9a3bf9..a6615e402571b57ffa6216a4e5ba863266f906d0 100644 (file)
@@ -539,6 +539,7 @@ static void api_list_sd_status_header(STATUS_PKT *sp)
 {
    char *p;
    alist drivers(10, not_owned_by_alist);
+   alist tlist(10, not_owned_by_alist);
    OutputWriter wt(sp->api_opts);
 
    sd_list_loaded_drivers(&drivers);
@@ -557,6 +558,9 @@ static void api_list_sd_status_header(STATUS_PKT *sp)
       OT_ALIST_STR, "drivers",  &drivers,
       OT_INT32,   "fips",       (int32_t)crypto_get_fips(),
       OT_STRING,   "openssl",   crypto_get_version(),
+      OT_INT64,  "debug",       debug_level,
+      OT_INT,    "trace",       get_trace(),
+      OT_ALIST_STR, "tags",     debug_get_tags_list(&tlist, debug_level_tags),
       OT_END);
    p = wt.end_group();
    sendit(p, strlen(p), sp);