diff --git a/changes/ticket40159 b/changes/ticket40159 new file mode 100644 index 0000000000000000000000000000000000000000..64840975440d6c6d3da2c3e1060685faf5a3d62a --- /dev/null +++ b/changes/ticket40159 @@ -0,0 +1,2 @@ + o Minor features (logging): + - Print directory fetch information a single line. Closes ticket 40159. diff --git a/src/feature/dirclient/dirclient.c b/src/feature/dirclient/dirclient.c index f088ef828356651733b8f8d96938b6278d20adba..c83c93f56d3f14dfa7060240c5c2b5bd494e888d 100644 --- a/src/feature/dirclient/dirclient.c +++ b/src/feature/dirclient/dirclient.c @@ -1987,7 +1987,7 @@ dirclient_dump_total_dls(void) { const or_options_t *options = get_options(); for (int bootstrapped = 0; bootstrapped < 2; ++bootstrapped) { - bool first_time = true; + smartlist_t *lines = smartlist_new(); for (int i=0; i < DIR_PURPOSE_MAX_; ++i) { uint64_t n = total_dl[i][bootstrapped]; if (n == 0) @@ -1995,15 +1995,20 @@ dirclient_dump_total_dls(void) if (options->SafeLogging_ != SAFELOG_SCRUB_NONE && purpose_needs_anonymity(i, ROUTER_PURPOSE_GENERAL, NULL)) continue; - if (first_time) { - log_notice(LD_NET, - "While %sbootstrapping, fetched this many bytes: ", - bootstrapped?"not ":""); - first_time = false; - } - log_notice(LD_NET, " %"PRIu64" (%s)", - n, dir_conn_purpose_to_string(i)); + char *line = NULL; + tor_asprintf(&line, "%"PRIu64" (%s)", n, dir_conn_purpose_to_string(i)); + smartlist_add(lines, line); + } + + if (smartlist_len(lines) > 0) { + char *log_line = smartlist_join_strings(lines, "; ", 0, NULL); + log_notice(LD_NET, "While %sbootstrapping, fetched this many bytes: %s", + bootstrapped?"not ":"", log_line); + tor_free(log_line); + + SMARTLIST_FOREACH(lines, char *, s, tor_free(s)); } + smartlist_free(lines); } }