Skip to content
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

Allow configuring logging directory through environment variables #53

Conversation

christophebedard
Copy link
Member

@christophebedard christophebedard commented Sep 22, 2020

This allows configuring the logging directory through environment variables using the following logic:

  • Use $ROS_LOG_DIR if ROS_LOG_DIR is set and not empty.
  • Otherwise, use $ROS_HOME/log, using ~/.ros for ROS_HOME if not set or if empty.

Since this function is meant to be used by all logging implementations, I put it in rcl_logging_interface. I also added a test.

Closes #50

Requires ros2/rcpputils#98

@christophebedard
Copy link
Member Author

Since this function is meant to be used by all logging implementations, I put it in rcl_logging_interface.

But maybe it shouldn't be RCL_LOGGING_INTERFACE_PUBLIC/in the header directly?

@christophebedard
Copy link
Member Author

@ros-pull-request-builder retest this please

@christophebedard
Copy link
Member Author

oh, build.ros.org doesn't build everything from source.

Signed-off-by: Christophe Bedard <bedard.christophe@gmail.com>
@christophebedard christophebedard force-pushed the allow-configuring-logging-dir-through-env-vars branch from e8cf2b8 to 07dfba4 Compare September 25, 2020 14:11
@christophebedard
Copy link
Member Author

@jacobperron could you take a look?

@ivanpauno ivanpauno self-requested a review September 29, 2020 14:40
Copy link
Member

@ivanpauno ivanpauno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have left a bunch of comment here and there, but this seems to be going in the right direction.
Thanks for working on this @christophebedard !

@ivanpauno
Copy link
Member

By the way, the PR checker isn't passing.

@ivanpauno
Copy link
Member

After addressing comments here, we should also update the logging tutorial: https://index.ros.org/doc/ros2/Tutorials/Logging-and-logger-configuration/.

Signed-off-by: Christophe Bedard <bedard.christophe@gmail.com>
Signed-off-by: Christophe Bedard <bedard.christophe@gmail.com>
Signed-off-by: Christophe Bedard <bedard.christophe@gmail.com>
@christophebedard
Copy link
Member Author

By the way, the PR checker isn't passing.

yeah, it requires ros2/rcpputils#98

Signed-off-by: Christophe Bedard <bedard.christophe@gmail.com>
Signed-off-by: Christophe Bedard <bedard.christophe@gmail.com>
Signed-off-by: Christophe Bedard <bedard.christophe@gmail.com>
Signed-off-by: Christophe Bedard <bedard.christophe@gmail.com>
Signed-off-by: Christophe Bedard <bedard.christophe@gmail.com>
Signed-off-by: Christophe Bedard <bedard.christophe@gmail.com>
Signed-off-by: Christophe Bedard <bedard.christophe@gmail.com>
Signed-off-by: Christophe Bedard <bedard.christophe@gmail.com>
Signed-off-by: Christophe Bedard <bedard.christophe@gmail.com>
Signed-off-by: Christophe Bedard <bedard.christophe@gmail.com>
@christophebedard
Copy link
Member Author

christophebedard commented Sep 30, 2020

rcutils_format_string has an implicit 2048 max length, for some strange reason (see here).

I assumed 2048 was enough, but yeah there's no point in restricting it. I changed it in 49fdcd8

oh I missed your edit

@christophebedard
Copy link
Member Author

@ros-pull-request-builder retest this please

@christophebedard
Copy link
Member Author

Hope you don't mind, here's CI for this PR + ros2/launch#460 with --packages-above[-and-dependencies] rcl_logging_interface rcl_logging_log4cxx rcl_logging_noop rcl_logging_spdlog launch launch_xml launch_yaml:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

Signed-off-by: Christophe Bedard <bedard.christophe@gmail.com>
@christophebedard
Copy link
Member Author

christophebedard commented Oct 10, 2020

like @ivanpauno pointed out previously, the tests aren't passing on Windows because they're using / as a path separator in environment variables. I'm just wondering which solution is more appropriate:

  1. change the tests to use the right path separator in the env var values, e.g. by #ifdefing or calling rcutils_to_native_path, or
  2. calling rcutils_to_native_path at the end of rcl_logging_get_logging_directory (although this would still require a bit of option 1)

Note that, in the Logging and logger configuration tutorial, I used forward slashes for Windows, so it wouldn't currently work with option 1: https://index.ros.org/doc/ros2/Tutorials/Logging-and-logger-configuration/#logging-directory-configuration

Signed-off-by: Christophe Bedard <bedard.christophe@gmail.com>
@christophebedard
Copy link
Member Author

christophebedard commented Oct 10, 2020

I ended up going with option 2 (+ a bit of option 1, as mentioned above) because it's more resilient: c8aae9e

I've also made the same modification in ros2/launch#460. Let me know what you think. I've tested on both Ubuntu and Windows. Here's a CI rebuild:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

Signed-off-by: Christophe Bedard <bedard.christophe@gmail.com>
@christophebedard
Copy link
Member Author

I missed the MSBuild warning in the first CI run. Should be fixed in 1a4f0e0.

Windows rebuild:

  • Windows Build Status

Copy link
Contributor

@clalancette clalancette left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All right, this is starting to look better. I still found a few more memory leaks to clean up.

Signed-off-by: Christophe Bedard <bedard.christophe@gmail.com>
Signed-off-by: Christophe Bedard <bedard.christophe@gmail.com>
Signed-off-by: Christophe Bedard <bedard.christophe@gmail.com>
@christophebedard christophebedard force-pushed the allow-configuring-logging-dir-through-env-vars branch from dd0a976 to 97f6824 Compare October 13, 2020 12:11
Copy link
Contributor

@clalancette clalancette left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me now. Thanks for the iterations.

I'll run CI on it next.

@clalancette
Copy link
Contributor

CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@ivanpauno
Copy link
Member

Merging together with ros2/launch#460, thanks @christophebedard for the contribution!

@ivanpauno ivanpauno merged commit e2456ba into ros2:master Oct 13, 2020
@christophebedard christophebedard deleted the allow-configuring-logging-dir-through-env-vars branch October 13, 2020 21:30
@christophebedard
Copy link
Member Author

thank you for the review @ivanpauno et al. 😄

@tgreier
Copy link

tgreier commented Dec 21, 2020

I would like to backport this PR to Foxy with ros2/launch#460. However, the rcl_logging_interface was never merged into Foxy. I would need to backport quite a bit to get to this PR. I would first need to backport #41 and then move forward.
Do you think that it is ok to do that?

@ivanpauno
Copy link
Member

I would like to backport this PR to Foxy with ros2/launch#460. However, the rcl_logging_interface was never merged into Foxy. I would need to backport quite a bit to get to this PR. I would first need to backport #41 and then move forward.
Do you think that it is ok to do that?

cc @jacobperron

@tgreier
Copy link

tgreier commented Dec 21, 2020

@jacobperron @ivanpauno
I backported (locally) #41 and #53 and I now get the functionality that I want from ros2/launch#460.
Is this acceptable to do or are there additional PRs/commits that I should backport between #41 and #53?
I will need at least #51 and #52.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Configure logging directory
5 participants