Skip to content

Option for uncolored log output #2592

@christophfroehlich

Description

@christophfroehlich

Is your feature request related to a problem? Please describe.
Our CI logs always look like
[NON-XML-CHAR-0x1B][96mSetting controller param "type" to "imu_sensor_broadcaster/IMUSensorBroadcaster" for [NON-XML-CHAR-0x1B][1mimu14_sensor_broadcaster[NON-XML-CHAR-0x1B][0m

Describe the solution you'd like
From https://docs.ros.org/en/humble/Concepts/Intermediate/About-Logging.html

RCUTILS_COLORIZED_OUTPUT - Control whether colors are used when outputting messages. If unset, automatically determine based on the platform and whether the console is a TTY. If 0, force disable using colors for output. If 1, force enable using colors for output.

Let's use the same logic as (tbd: is there an equivalent of isatty for python?)

https://github.com/ros2/rcutils/blob/3bbdf935477c2ba999943085abd4fbfe8d2867ce/src/logging.c#L1400-L1406

and don't add these colors in spawners etc

# from https://stackoverflow.com/a/287944
class bcolors:
MAGENTA = "\033[95m"
OKBLUE = "\033[94m"
OKCYAN = "\033[96m"
OKGREEN = "\033[92m"
WARNING = "\033[93m"
FAIL = "\033[91m"
ENDC = "\033[0m"
BOLD = "\033[1m"
UNDERLINE = "\033[4m"

Metadata

Metadata

Assignees

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions