diff options
author | Peter Rajnoha <prajnoha@redhat.com> | 2016-05-19 12:19:48 +0200 |
---|---|---|
committer | Peter Rajnoha <prajnoha@redhat.com> | 2016-06-20 11:33:42 +0200 |
commit | f50d4011cdd3ef38c15b9dea05e73321592d93c2 (patch) | |
tree | d3231d97b4f24232bf19a70b1429814264426c22 /libdm/libdm-report.c | |
parent | fe63715f25cf156b07e144a2e7b5cce56d32e39e (diff) | |
download | lvm2-f50d4011cdd3ef38c15b9dea05e73321592d93c2.tar.gz |
log: also pass log_print through report and add log_print_bypass_report for use in libdm-report for direct print without report
log_print is used during cmd line processing to log the result of the
operation (e.g. "Volume group vg successfully changed" and similar).
We don't want output from log_print to be interleaved with current
reports from group where log is reported as well. Also, the information
printed by log_print belongs to the log report too, so it should be
rerouted to log report if it's set.
Since the code in libdm-report which is responsible for doing the report
output uses log_print too, we need to use a different kind of log_print
which bypasses any log report currently used for logging (...simply,
we can't call log_print to output the log report itself which in turn
would again reroute to report - the report would never get on output
this way).
Diffstat (limited to 'libdm/libdm-report.c')
-rw-r--r-- | libdm/libdm-report.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/libdm/libdm-report.c b/libdm/libdm-report.c index 485bbdf9a..3fa596e3b 100644 --- a/libdm/libdm-report.c +++ b/libdm/libdm-report.c @@ -4105,7 +4105,7 @@ static int _report_headings(struct dm_report *rh) /* print all headings */ heading = (char *) dm_pool_end_object(rh->mem); - log_print("%s", heading); + log_print_bypass_report("%s", heading); dm_pool_free(rh->mem, (void *)heading); dm_free(buf); @@ -4422,7 +4422,7 @@ static int _output_as_rows(struct dm_report *rh) log_error("dm_report: Failed to terminate row"); goto bad; } - log_print("%s", (char *) dm_pool_end_object(rh->mem)); + log_print_bypass_report("%s", (char *) dm_pool_end_object(rh->mem)); } _destroy_rows(rh); @@ -4510,7 +4510,7 @@ static int _output_as_columns(struct dm_report *rh) } line = (char *) dm_pool_end_object(rh->mem); - log_print("%*s", rh->group_item ? rh->group_item->group->indent + (int) strlen(line) : 0, line); + log_print_bypass_report("%*s", rh->group_item ? rh->group_item->group->indent + (int) strlen(line) : 0, line); dm_list_del(&row->list); } @@ -4560,14 +4560,14 @@ static int _json_output_array_start(struct dm_pool *mem, struct report_group_ite } if (item->parent->store.finished_count > 0) - log_print("%*s", item->group->indent + (int) sizeof(JSON_SEPARATOR) - 1, JSON_SEPARATOR); + log_print_bypass_report("%*s", item->group->indent + (int) sizeof(JSON_SEPARATOR) - 1, JSON_SEPARATOR); if (item->parent->parent && item->parent->data) { - log_print("%*s", item->group->indent + (int) sizeof(JSON_OBJECT_START) - 1, JSON_OBJECT_START); + log_print_bypass_report("%*s", item->group->indent + (int) sizeof(JSON_OBJECT_START) - 1, JSON_OBJECT_START); item->group->indent += JSON_INDENT_UNIT; } - log_print("%*s", item->group->indent + (int) strlen(output), output); + log_print_bypass_report("%*s", item->group->indent + (int) strlen(output), output); item->group->indent += JSON_INDENT_UNIT; dm_pool_free(mem, output); @@ -4616,9 +4616,9 @@ static int _print_basic_report_header(struct dm_report *rh) memset(underline, '=', len); if (rh->group_item->parent->store.finished_count > 0) - log_print("%s", ""); - log_print("%s", report_name); - log_print("%s", underline); + log_print_bypass_report("%s", ""); + log_print_bypass_report("%s", report_name); + log_print_bypass_report("%s", underline); dm_pool_free(rh->mem, underline); return 1; @@ -4665,7 +4665,7 @@ static int _report_group_create_basic(struct dm_report_group *group) static int _report_group_create_json(struct dm_report_group *group) { - log_print(JSON_OBJECT_START); + log_print_bypass_report(JSON_OBJECT_START); group->indent += JSON_INDENT_UNIT; return 1; } @@ -4742,7 +4742,7 @@ static int _report_group_push_single(struct report_group_item *item, void *data) static int _report_group_push_basic(struct report_group_item *item, const char *name) { if (!item->report && !name && item->parent->store.finished_count > 0) - log_print("%s", ""); + log_print_bypass_report("%s", ""); return 1; } @@ -4769,8 +4769,8 @@ static int _report_group_push_json(struct report_group_item *item, const char *n return 0; } if (item->parent->store.finished_count > 0) - log_print("%*s", item->group->indent + (int) sizeof(JSON_SEPARATOR) - 1, JSON_SEPARATOR); - log_print("%*s", item->group->indent + (int) sizeof(JSON_OBJECT_START) - 1, JSON_OBJECT_START); + log_print_bypass_report("%*s", item->group->indent + (int) sizeof(JSON_SEPARATOR) - 1, JSON_SEPARATOR); + log_print_bypass_report("%*s", item->group->indent + (int) sizeof(JSON_OBJECT_START) - 1, JSON_OBJECT_START); item->group->indent += JSON_INDENT_UNIT; } @@ -4848,11 +4848,11 @@ static int _report_group_pop_json(struct report_group_item *item) if (item->output_done && item->needs_closing) { if (item->data) { item->group->indent -= JSON_INDENT_UNIT; - log_print("%*s", item->group->indent + (int) sizeof(JSON_ARRAY_END) - 1, JSON_ARRAY_END); + log_print_bypass_report("%*s", item->group->indent + (int) sizeof(JSON_ARRAY_END) - 1, JSON_ARRAY_END); } if (item->parent->data && item->parent->parent) { item->group->indent -= JSON_INDENT_UNIT; - log_print("%*s", item->group->indent + (int) sizeof(JSON_OBJECT_END) - 1, JSON_OBJECT_END); + log_print_bypass_report("%*s", item->group->indent + (int) sizeof(JSON_OBJECT_END) - 1, JSON_OBJECT_END); } item->needs_closing = 0; } @@ -4915,7 +4915,7 @@ static int _report_group_destroy_basic(void) static int _report_group_destroy_json(void) { - log_print(JSON_OBJECT_END); + log_print_bypass_report(JSON_OBJECT_END); return 1; } |