-
Notifications
You must be signed in to change notification settings - Fork 103
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
All logging to the same stream #196
Conversation
With the change in semantic the option name doesn't reflect what it does anymore. I would suggest to change the env var name to something indicating that it changes the default logging stream from
Options 1 and 2 sound like hacks to me. I think we should a) certainly support option 3. in |
Another option that came to mind is to always use the stdout stream, but have the command-line option toggle between buffered and unbuffered mode. Bonus points for making it 4 way configurable with stdout/stderr choice and buffered/unbuffered choice, with the default being stdout/unbuffered. |
I agree that the env var name no longer makes sense. Why not update the tests to match output to stderr (and also set an environment variable to ensure that's the logger's behavior)? It's possible to route stderr to stdout so they are captured together, but that option isn't exposed at the moment to the It looks like @pbaughman can you comment on that? But it should be possible, as |
@wjwwood I am happy to comment! launch_testing actually captures both stdout and stderr in the proc_output handler but currently only has built-in support for asserting about stdout It would be a pretty simple improvement to add built-in assertions for stderr too. |
+1 for fixing our tests and launch_testing to work with stderr. |
a3f04b1
to
5c882db
Compare
All right, I've done a bunch of work here to fix this up. Besides this PR, we need (at least): |
d3538f7
to
a16b5cc
Compare
With ros2/ros2#869 , this should be much closer to green. I'm going to kick off a full round of CI on all platforms to see if there is anything else I missed: |
All right. All of the reported failures in the CI job were also on the buildfarm, so I don't think this series of PRs is causing the problem. This is ready for another round of review, along with the connected PRs. |
Not sure if you caught this, but there are new MSBuild warnings with this build: https://ci.ros2.org/job/ci_windows-container/130/warnings43Result/new/package.-1236367313/ |
I always miss them. Thanks for pointing it out, I'll look to see what we do elsewhere. |
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.
Looking good, pending green CI
// something we don't understand. Return RCUTILS_GET_ENV_ZERO if the value in the | ||
// environment variable is "0", RCUTILS_GET_ENV_ONE if the value in the environment | ||
// variable is "1", or RCUTILS_GET_ENV_DEFAULT if the environment variables is empty. | ||
static enum rcutils_get_env_retval rcutils_get_env_var_zero_or_one( |
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.
@clalancette nit: any reason not to use Doxygen
syntax?
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.
@clalancette nit: any reason not to use
Doxygen
syntax?
Not particularly. This is an internal function, so I didn't think it was necessary, but I'll claim ignorance on what our policy is for comments on internal functions.
include/rcutils/strerror.h
Outdated
|
||
RCUTILS_PUBLIC | ||
void | ||
rcutils_safe_strerror(char * buffer, size_t buffer_length); |
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.
@clalancette missing docblock
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.
Oops, yeah, good call. Added in 9200c9f
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.
How about removing safe
from the name of the function?
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.
I took the name from https://github.com/ros2/rclcpp/blob/2d9c6ea3a77103b91f7984269d163037961a4c04/rclcpp/src/rclcpp/signal_handler.cpp#L164 . But I don't have a strong opinion, so we can just switch it to rcutils_strerror
if you prefer.
5dc1b09
to
9200c9f
Compare
Nitpick: each sentence in a comment / docblock should start on a new line. |
Regarding the env var names: I am not convinced the prefix |
include/rcutils/strerror.h
Outdated
|
||
RCUTILS_PUBLIC | ||
void | ||
rcutils_safe_strerror(char * buffer, size_t buffer_length); |
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.
How about removing safe
from the name of the function?
That's true. I think I'll go with something like |
stderr, "Invalid return from environment fetch\n"); | ||
RCUTILS_SET_ERROR_MSG( | ||
"Invalid return from environment fetch"); | ||
return RCUTILS_RET_ERROR; |
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.
I'm not a huge fan of setting the error state and printing to stderr. In my opinion, libraries shouldn't print to stderr unless there's no other way to raise an issue. This function can raise an issue with the return code and error state.
Again, I know this is the case already in this file, but I felt I should bring it up as long as we're looking at this file.
This follows the convention for human-readable diagnostic output on Linux systems. fix #168 Make the stream configurable. We default the stream to stderr, but allow the user to change it to stdout by setting RCUTILS_CONSOLE_LINE_BUFFERED to 1. Signed-off-by: Dan Rose <dan@digilabs.io> Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
And switch to using 'setvbuf', which allows us to get rid of flush semantic during runtime. Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
Used in the logging stuff, and elsewhere in the codebase. Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
30d5add
to
8abac20
Compare
Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
I've now responded to most of the open comments. The ones remaining are as follows:
So with that, I think this is ready for another round of review. |
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.
Change
rcutils_safe_strerror
->rcutils_strerror
. I think having the safe in here is a good additional hint that this is a thread-safe version of strerror, so I'm going to leave it.
I think it would be good to remove it now since other thread-safe API doesn't contain that as part of their name either.
- and 3.
👍 to keep those changes separate.
Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
This PR is a rehash of the now-closed #181. In particular, this PR proposes to make it so that all output from all logging levels go to the same stream. This replicates the behavior of basically all other logging systems; see #181 (comment) for details.
Compared to #181, this PR is now rebased on master, and has made it so that the stream that all output goes to is configurable. The default is stderr/unbuffered (so that error messages go out right away), but if users want a very minor performance improvement, they can switch it to stdout/buffered by setting
RCUTILS_CONSOLE_LINE_BUFFERED=1
.Unfortunately, the change to stderr by default means that a lot of tests in the ROS 2 core (and probably beyond) are going to start failing. That's because those tests are typically trying to capture stdout output, and there is no longer any output there. Solutions I can think of:
RCUTILS_CONSOLE_LINE_BUFFERED=1
(this will fix it in the core, but still leave downstream consumers with failing tests).@ros2/team Opinions on how to proceed with fixing tests appreciated.
@rotu FYI
Fixes #168