Skip to content

Provide a mechanism to disable color output #611

@azeey

Description

@azeey

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: �[m�[32m[Msg] �[m�[32mServing world names on [�[m�[32m/gazebo/worlds�[m�[32m]�[m�[32m
213: �[m�[32m[Msg] �[m�[32mResource path add service on [�[m�[32m/gazebo/resource_paths/add�[m�[32m].�[m�[32m
213: �[m�[32m[Msg] �[m�[32mResource path get service on [�[m�[32m/gazebo/resource_paths/get�[m�[32m].�[m�[32m
213: �[m�[32m[Msg] �[m�[32mResource path resolve service on [�[m�[32m/gazebo/resource_paths/resolve�[m�[32m].�[m�[32m
213: �[m�[32m[Msg] �[m�[32mResource paths published on [�[m�[32m/gazebo/resource_paths�[m�[32m].�[m�[32m
213: �[m�[32m[Msg] �[m�[32mServer control service on [�[m�[32m/server_control�[m�[32m].�[m�[32m

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

To do

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions