gazebosim/gz-common

Provide a mechanism to disable color output

オープン

#611 opened on 2024/05/29

 (1 件のコメント) (0 件のリアクション) (1 人の担当者)C++ (59 件のフォーク)auto 404
enhancementgood first issue

Repository metrics

Stars
 (28 個のスター)
PR merge metrics
 (平均マージ 9d 6h) (30d で 30 merged PRs)

説明

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

コントリビューターガイド