Use BABELTRACE_FORCE_COLORS environment variable to force color support
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 14 Jun 2017 02:42:58 +0000 (22:42 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 14 Jun 2017 19:17:13 +0000 (15:17 -0400)
This allows this use case:

    BABELTRACE_FORCE_COLORS=1 babeltrace ... |& less -R

to see the logging's color in `less`.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
common/common.c

index 609975f7ec749bc9436f0b7889d257a7433dde9d..96532e2bd8bfe0c3a33ca556b2cef3006be1528e 100644 (file)
@@ -240,6 +240,7 @@ bool bt_common_colors_supported(void)
        static bool supports_colors = false;
        static bool supports_colors_set = false;
        const char *term;
+       const char *force;
 
        if (supports_colors_set) {
                goto end;
@@ -247,6 +248,12 @@ bool bt_common_colors_supported(void)
 
        supports_colors_set = true;
 
+       force = getenv("BABELTRACE_FORCE_COLORS");
+       if (force && strcmp(force, "1") == 0) {
+               supports_colors = true;
+               goto end;
+       }
+
        term = getenv("TERM");
        if (!term) {
                goto end;
This page took 0.026257 seconds and 4 git commands to generate.