add functionality to enable color logging for ros2launch messages#945
Open
andreas-loeffler wants to merge 1 commit intoros2:rollingfrom
Open
add functionality to enable color logging for ros2launch messages#945andreas-loeffler wants to merge 1 commit intoros2:rollingfrom
andreas-loeffler wants to merge 1 commit intoros2:rollingfrom
Conversation
Signed-off-by: Andreas Loeffler <73336148+andreas-loeffler@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds color logging support to the launch system. Currently the logs of individual nodes run from the launch file can be colorized using e.g. emulate_tty, however the messages generated by ros2launch itself (e.g., "process started", "process has died", and log tags [INFO] or [ERROR]) remained unaffected/non-colored.
Corresponding tests to the colorlog functionality have been added too.
(a) ros2 launch using the newly added colorlogging

(b) old behavior in which RCUTILS_COLORIZED_OUTPUT or emulaty_tty did not affect the color logging ability of ros2launch messages

Fixes #942
Is this user-facing behavior change?
Yes. Users will now see colorized log output for ros2launch events when running in a tty or when RCUTILS_COLORIZED_OUTPUT=1
Did you use Generative AI?
No
Additional Information
The contains_ansicode helper function used for the added tests is derived from the ansi regex check posted here: https://stackoverflow.com/questions/68556358/how-to-check-for-ansi-character-in-python
Since the PR adds a new python3 dependency (python3-colorlog) the corresponding rosdep key was already added. See add python3-colorlog key for ubuntu ros/rosdistro#49860