Move opt_field_names/babeltrace_verbose/babeltrace_debug into lib
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 2 Nov 2011 12:13:16 +0000 (08:13 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 2 Nov 2011 12:13:16 +0000 (08:13 -0400)
Introduce BABELTRACE_VERBOSE and BABELTRACE_DEBUG env. var.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
converter/babeltrace-lib.c
converter/babeltrace.c
formats/ctf-text/ctf-text.c

index ac3bd7c621bd7417ba0f23dde20d1f03390290ec..075362175970858ccd919a84750aa7f59a0ed8ef 100644 (file)
@@ -34,6 +34,8 @@
 #include <babeltrace/ctf-ir/metadata.h>
 #include <stdarg.h>
 
+int babeltrace_verbose, babeltrace_debug;
+
 struct stream_saved_pos {
        /*
         * Use file_stream pointer to check if the trace collection we
@@ -609,3 +611,12 @@ end:
        babeltrace_iter_destroy(iter);
        return ret;
 }
+
+static
+void __attribute__((constructor)) init_babeltrace_lib(void)
+{
+       if (getenv("BABELTRACE_VERBOSE"))
+               babeltrace_verbose = 1;
+       if (getenv("BABELTRACE_DEBUG"))
+               babeltrace_debug = 1;
+}
index be546750e96921b55fb871ae8aa70ddd7c6f3f76..04d2615e788dd470693c9d7a10a13b2f33545d4f 100644 (file)
@@ -40,9 +40,6 @@ static char *opt_output_format;
 static const char *opt_input_path;
 static const char *opt_output_path;
 
-int babeltrace_verbose, babeltrace_debug;
-int opt_field_names;
-
 static struct trace_collection trace_collection_read;
 static struct format *fmt_read;
 
@@ -95,7 +92,9 @@ static void usage(FILE *fp)
        fprintf(fp, "  -h, --help                     This help message\n");
        fprintf(fp, "  -l, --list                     List available formats\n");
        fprintf(fp, "  -v, --verbose                  Verbose mode\n");
+       fprintf(fp, "                                 (or set BABELTRACE_VERBOSE env. var.)\n");
        fprintf(fp, "  -d, --debug                    Debug mode\n");
+       fprintf(fp, "                                 (or set BABELTRACE_DEBUG env. var.)\n");
        fprintf(fp, "  -n, --names                    Print field names\n");
        list_formats(fp);
        fprintf(fp, "\n");
index f1c1f037a1e979d5301650bae1b39f805a9b44de..b8673755255c037649255d46c5a36392cd51ec56 100644 (file)
@@ -34,6 +34,8 @@
 #include <unistd.h>
 #include <stdlib.h>
 
+int opt_field_names;
+
 struct trace_descriptor *ctf_text_open_trace(const char *path, int flags,
                void (*move_pos_slow)(struct ctf_stream_pos *pos, size_t offset,
                        int whence), FILE *metadata_fp);
This page took 0.026215 seconds and 4 git commands to generate.