gazebosim/gz-common

Provide a mechanism to disable color output

开放

#611 创建于 2024年5月29日

 (1 条评论) (0 个反应) (1 位负责人)C++ (59 个派生)auto 404
enhancementgood first issue

仓库指标

星标
 (28 个星标)
PR 合并指标
 (平均合并 9天 6小时) (30 天内合并 30 个 PR)

描述

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

贡献者指南