Commit 29065db3 authored by Alex Xu's avatar Alex Xu
Browse files

dirclient: print bandwidth usage on one line (#40159)

parent c4812698
o Minor features (logging):
- Print directory fetch information a single line. Closes ticket 40159.
...@@ -1987,7 +1987,7 @@ dirclient_dump_total_dls(void) ...@@ -1987,7 +1987,7 @@ dirclient_dump_total_dls(void)
{ {
const or_options_t *options = get_options(); const or_options_t *options = get_options();
for (int bootstrapped = 0; bootstrapped < 2; ++bootstrapped) { 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) { for (int i=0; i < DIR_PURPOSE_MAX_; ++i) {
uint64_t n = total_dl[i][bootstrapped]; uint64_t n = total_dl[i][bootstrapped];
if (n == 0) if (n == 0)
...@@ -1995,15 +1995,20 @@ dirclient_dump_total_dls(void) ...@@ -1995,15 +1995,20 @@ dirclient_dump_total_dls(void)
if (options->SafeLogging_ != SAFELOG_SCRUB_NONE && if (options->SafeLogging_ != SAFELOG_SCRUB_NONE &&
purpose_needs_anonymity(i, ROUTER_PURPOSE_GENERAL, NULL)) purpose_needs_anonymity(i, ROUTER_PURPOSE_GENERAL, NULL))
continue; continue;
if (first_time) { char *line = NULL;
log_notice(LD_NET, tor_asprintf(&line, "%"PRIu64" (%s)", n, dir_conn_purpose_to_string(i));
"While %sbootstrapping, fetched this many bytes: ", smartlist_add(lines, line);
bootstrapped?"not ":""); }
first_time = false;
} if (smartlist_len(lines) > 0) {
log_notice(LD_NET, " %"PRIu64" (%s)", char *log_line = smartlist_join_strings(lines, "; ", 0, NULL);
n, dir_conn_purpose_to_string(i)); 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);
} }
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment