-
Notifications
You must be signed in to change notification settings - Fork 111
Add colorized output #158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add colorized output #158
Conversation
Signed-off-by: ivanpauno <[email protected]>
|
It would be good to have an env var to control the behavior (force enable, force disable) and the default could be based on if the shell is interactive (if I recall correctly that is what other cases use). |
…t variable. * Stop adding colours in `rcutils_logging_format_message`. Add colours only in `rcutils_logging_console_output_handler`. Signed-off-by: ivanpauno <[email protected]>
I added an env I also moved the "add colour logic " from |
|
An unrelated comment: Lines 77 to 98 in 343e406
Also, I think all the code related to @dirk-thomas if you agree, I will open another PR correcting that. |
Let's use standard boolean values for the new env var |
Signed-off-by: ivanpauno <[email protected]>
Done! |
Signed-off-by: ivanpauno <[email protected]>
Signed-off-by: ivanpauno <[email protected]>
Signed-off-by: ivanpauno <[email protected]>
Signed-off-by: ivanpauno <[email protected]>
| } else { \ | ||
| is_colorized = isatty(fileno(stream)) != 0; \ | ||
| } \ | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This macro is almost identical to the Windows implementation above. Please avoid that duplication and only customize the isatty call using a platform specific macro.
Signed-off-by: ivanpauno <[email protected]>
Signed-off-by: ivanpauno <[email protected]>
Signed-off-by: ivanpauno <[email protected]>
Signed-off-by: ivanpauno <[email protected]>
|
I have tested locally that linter is passing in both windows and linux after e407efd. I'm going to skip running ci jobs again only because of linter failures. |
|
Just to keep information in one place, I'll amend to this years old PR. When using I've added a documentation note about this caveat: ros2/ros2_documentation#5726 . |
It is just what the title says.
Working well in Linux. Colors were taken from ROS1:
https://github.com/ros/rosconsole/blob/ba4e1ae06b5bce3039ac5d20853248b51198e431/src/rosconsole/rosconsole.cpp#L75-L85
https://github.com/ros/rosconsole/blob/ba4e1ae06b5bce3039ac5d20853248b51198e431/src/rosconsole/rosconsole.cpp#L341-L363
I haven't tried it on MAC, but as far as I understand it should work as-is.
I could do something like this in windows if it is desired:
https://stackoverflow.com/questions/8765938/colorful-text-using-printf-in-c