gazebosim/gz-common

Provide a mechanism to disable color output

Open

#611 opened on May 29, 2024

View on GitHub
 (1 comment) (0 reactions) (1 assignee)C++ (59 forks)auto 404
enhancementgood first issue

Repository metrics

Stars
 (28 stars)
PR merge metrics
 (PR metrics pending)

Description

Desired behavior

ANSI Color codes are usually not interpreted on our Jenkins consoles and end up making the output difficult to read. Example from Jenkins:

213: [Msg] Serving world names on [/gazebo/worlds]
213: [Msg] Resource path add service on [/gazebo/resource_paths/add].
213: [Msg] Resource path get service on [/gazebo/resource_paths/get].
213: [Msg] Resource path resolve service on [/gazebo/resource_paths/resolve].
213: [Msg] Resource paths published on [/gazebo/resource_paths].
213: [Msg] Server control service on [/server_control].

Thus, it would be nice to provide a mechanism to remove the color output when it's not desired.

Alternatives considered

Pipe test output through ansi2txt. However, I'm not sure if this tool is available in all of our platforms.

Implementation suggestion

Disable color output via an environment variable. For example, GZ_CONSOLE_COLOR=no or GZ_CONSOLE_COLOR=0. gtest has GTEST_COLOR used for similar effect.

You can set the GTEST_COLOR environment variable or the --gtest_color command line flag to yes, no, or auto (the default) to enable colors, disable colors, or let GoogleTest decide. When the value is auto, GoogleTest will use colors if and only if the output goes to a terminal and (on non-Windows platforms) the TERM environment variable is set to xterm or xterm-color. -- https://google.github.io/googletest/advanced.html#colored-terminal-output

Contributor guide