From c8b219a3168dd382a167a72406e268550005e662 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Sat, 7 May 2011 01:27:01 -0400 Subject: [PATCH] prettify output Signed-off-by: Mathieu Desnoyers --- converter/babeltrace-lib.c | 3 +++ converter/babeltrace.c | 8 ++++---- formats/ctf-text/types/struct.c | 12 ++++++++---- formats/ctf/metadata/ctf-parser-test.c | 2 ++ .../ctf/metadata/ctf-visitor-generate-io-struct.c | 5 +++-- formats/ctf/metadata/ctf-visitor-parent-links.c | 1 + .../ctf/metadata/ctf-visitor-semantic-validator.c | 9 +++++---- formats/ctf/metadata/ctf-visitor-xml.c | 1 + tests/test-dummytrace.c | 2 +- 9 files changed, 28 insertions(+), 15 deletions(-) diff --git a/converter/babeltrace-lib.c b/converter/babeltrace-lib.c index 5be268cc..bd0e11e1 100644 --- a/converter/babeltrace-lib.c +++ b/converter/babeltrace-lib.c @@ -38,6 +38,9 @@ int convert_event(struct ctf_text_stream_pos *sout, if (sin->pos.offset == -EOF) return -EOF; + /* Hide event payload struct brackets */ + sout->depth = -1; + /* Read and print event header */ if (stream_class->event_header) { generic_rw(&sin->pos.parent, &stream_class->event_header->p); diff --git a/converter/babeltrace.c b/converter/babeltrace.c index c0c6541a..c888ec60 100644 --- a/converter/babeltrace.c +++ b/converter/babeltrace.c @@ -171,13 +171,13 @@ int main(int argc, char **argv) opt_output_format ? : "ctf"); if (!opt_input_format) { - fprintf(stdout, "Error: input format autodetection not implemented yet.\n\n"); + fprintf(stdout, "[error] Input format autodetection not implemented yet.\n\n"); usage(stdout); exit(EXIT_FAILURE); } fmt_read = bt_lookup_format(g_quark_from_static_string(opt_input_format)); if (!fmt_read) { - fprintf(stdout, "Error: format \"%s\" is not supported.\n\n", + fprintf(stdout, "[error] Format \"%s\" is not supported.\n\n", opt_input_format); exit(EXIT_FAILURE); } @@ -185,14 +185,14 @@ int main(int argc, char **argv) opt_output_format = "ctf"; fmt_write = bt_lookup_format(g_quark_from_static_string(opt_output_format)); if (!fmt_write) { - fprintf(stdout, "Error: format \"%s\" is not supported.\n\n", + fprintf(stdout, "[error] format \"%s\" is not supported.\n\n", opt_output_format); exit(EXIT_FAILURE); } td_read = fmt_read->open_trace(opt_input_path, O_RDONLY); if (!td_read) { - fprintf(stdout, "Error opening trace \"%s\" for reading.\n\n", + fprintf(stdout, "[error] opening trace \"%s\" for reading.\n\n", opt_input_path); goto error_td_read; } diff --git a/formats/ctf-text/types/struct.c b/formats/ctf-text/types/struct.c index cd63fe99..4270a21a 100644 --- a/formats/ctf-text/types/struct.c +++ b/formats/ctf-text/types/struct.c @@ -24,14 +24,18 @@ void ctf_text_struct_write(struct stream_pos *ppos, struct definition *definitio struct ctf_text_stream_pos *pos = ctf_text_pos(ppos); if (!pos->dummy) { - print_pos_tabs(pos); - fprintf(pos->fp, "{\n"); + if (pos->depth >= 0) { + print_pos_tabs(pos); + fprintf(pos->fp, "{\n"); + } pos->depth++; } struct_rw(ppos, definition); if (!pos->dummy) { pos->depth--; - print_pos_tabs(pos); - fprintf(pos->fp, "}\n"); + if (pos->depth >= 0) { + print_pos_tabs(pos); + fprintf(pos->fp, "}\n"); + } } } diff --git a/formats/ctf/metadata/ctf-parser-test.c b/formats/ctf/metadata/ctf-parser-test.c index fdde409e..ab4bc30c 100644 --- a/formats/ctf/metadata/ctf-parser-test.c +++ b/formats/ctf/metadata/ctf-parser-test.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include "ctf-scanner.h" #include "ctf-parser.h" @@ -35,6 +36,7 @@ int main(int argc, char **argv) int ret = 0; babeltrace_debug = 1; + babeltrace_verbose = 1; scanner = ctf_scanner_alloc(stdin); if (!scanner) { fprintf(stdout, "Error allocating scanner\n"); diff --git a/formats/ctf/metadata/ctf-visitor-generate-io-struct.c b/formats/ctf/metadata/ctf-visitor-generate-io-struct.c index ca1a83dd..033537e6 100644 --- a/formats/ctf/metadata/ctf-visitor-generate-io-struct.c +++ b/formats/ctf/metadata/ctf-visitor-generate-io-struct.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -1963,7 +1964,7 @@ int ctf_visitor_construct_metadata(FILE *fd, int depth, struct ctf_node *node, int ret = 0; struct ctf_node *iter; - fprintf(fd, "CTF visitor: metadata construction... "); + printf_verbose("CTF visitor: metadata construction... "); trace->root_declaration_scope = new_declaration_scope(NULL); trace->byte_order = byte_order; @@ -2011,6 +2012,6 @@ int ctf_visitor_construct_metadata(FILE *fd, int depth, struct ctf_node *node, (int) node->type); return -EINVAL; } - fprintf(fd, "done.\n"); + printf_verbose("done.\n"); return ret; } diff --git a/formats/ctf/metadata/ctf-visitor-parent-links.c b/formats/ctf/metadata/ctf-visitor-parent-links.c index 707f03a5..49d067c6 100644 --- a/formats/ctf/metadata/ctf-visitor-parent-links.c +++ b/formats/ctf/metadata/ctf-visitor-parent-links.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include "ctf-scanner.h" #include "ctf-parser.h" diff --git a/formats/ctf/metadata/ctf-visitor-semantic-validator.c b/formats/ctf/metadata/ctf-visitor-semantic-validator.c index 6385b0bd..af55eb48 100644 --- a/formats/ctf/metadata/ctf-visitor-semantic-validator.c +++ b/formats/ctf/metadata/ctf-visitor-semantic-validator.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include "ctf-scanner.h" #include "ctf-parser.h" @@ -862,15 +863,15 @@ int ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node) * take the safe route and recreate them at each validation, just in * case the structure has changed. */ - fprintf(fd, "CTF visitor: parent links creation... "); + printf_verbose("CTF visitor: parent links creation... "); ret = ctf_visitor_parent_links(fd, depth, node); if (ret) return ret; - fprintf(fd, "done.\n"); - fprintf(fd, "CTF visitor: semantic check... "); + printf_verbose("done.\n"); + printf_verbose("CTF visitor: semantic check... "); ret = _ctf_visitor_semantic_check(fd, depth, node); if (ret) return ret; - fprintf(fd, "done.\n"); + printf_verbose("done.\n"); return ret; } diff --git a/formats/ctf/metadata/ctf-visitor-xml.c b/formats/ctf/metadata/ctf-visitor-xml.c index 96145f8b..f73c3671 100644 --- a/formats/ctf/metadata/ctf-visitor-xml.c +++ b/formats/ctf/metadata/ctf-visitor-xml.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include "ctf-scanner.h" #include "ctf-parser.h" diff --git a/tests/test-dummytrace.c b/tests/test-dummytrace.c index ca79115f..06bb695b 100644 --- a/tests/test-dummytrace.c +++ b/tests/test-dummytrace.c @@ -32,7 +32,7 @@ #include #include -int babeltrace_debug = 0; +int babeltrace_debug, babeltrace_verbose; static uuid_t s_uuid; -- 2.34.1