Skip to content

Changing the default location for log files to be a local directory instead of /var/log/ros on linux due to permission issues.#9

Merged
nuclearsandwich merged 5 commits intomasterfrom
log_location_fix
May 6, 2019
Merged

Changing the default location for log files to be a local directory instead of /var/log/ros on linux due to permission issues.#9
nuclearsandwich merged 5 commits intomasterfrom
log_location_fix

Conversation

@nburek
Copy link
Copy Markdown
Contributor

@nburek nburek commented May 2, 2019

During the review of this PR: ros2/rcl#425 we found that there were permission issues with writing to /var/log. The quick fix for this is to use the same behavior that we have on Windows, which is to log to a local directory instead.

@dirk-thomas
Copy link
Copy Markdown
Member

Please use ~/.ros/log as the default base path for any logging (same as in ROS 2 launch as well as ROS 1). Within that directory please choose a scheme which allows multiple log files from multiple processes to write their data into different files.

@clalancette
Copy link
Copy Markdown
Contributor

@nburek We're going to look at changing this to use ~/.ros/log today to be more like ROS 1. I'll update this PR with any patches/updates as we make the change. Let me know if you have any questions or input.

@clalancette
Copy link
Copy Markdown
Contributor

Update:

I have a prototype that puts logs in ~/.ros/log/<exe>-<pid>-<ms_since_epoch>.log, which is the format used in ROS 1. I've tested that prototype to work well on Linux.

As part of the prototype, I needed an API change to the external logger initialization so I could allocate memory. That is now in as #10 and ros2/rcl#430 .

There is also a need to add some rcutils methods to support things like getting the home directory, executable name, etc. in a cross-platform way. But since those are strictly API additions, they can come later.

Tomorrow I'll do some additional cleanup on the prototype, test it on Windows and macOS, and then open the PR to rcutils and update this PR with my latest code.

…nstead of /var/log/ros on linux due to permission issues.
This works on Linux, but still needs to be cleaned
up and tested on macOS/Windows.

Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
clalancette and others added 3 commits May 3, 2019 19:31
Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
Copy link
Copy Markdown
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.

I'm approving, but since I did a bunch of new work here, it's probably best if someone else reviews as well. @nuclearsandwich @wjwwood , mind reviewing this as well?

@nburek
Copy link
Copy Markdown
Contributor Author

nburek commented May 6, 2019

I can't approve since I created the original PR, but the changes look good to me.

@nuclearsandwich nuclearsandwich merged commit 4b5ae3b into master May 6, 2019
@delete-merged-branch delete-merged-branch bot deleted the log_location_fix branch May 6, 2019 20:22
}

char log_name_buffer[512] = {0};
snprintf(log_name_buffer, sizeof(log_name_buffer), "%s/.ros/log/%s_%i_%" PRId64 ".log", homedir, basec, rcutils_get_pid(), ms_since_epoch);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This line looks really long, is there any linting happening in this file?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That's true. The linter isn't enabled on this package. I'll open an issue to track turning on the linter and dealing with the fallout.

int64_t ms_since_epoch = RCUTILS_NS_TO_MS(now);

// Get the program name.
char *basec = rcutils_get_executable_name(allocator);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just curious what does basec mean? Why not executable_name?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It is short for "basename copy", but I agree that executable_name would be a better term. I'll do a followup PR tomorrow to rename this.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I agree that executable_name would be a better term. I'll do a followup PR tomorrow to rename this.

I've already got this WIP.

add_compile_options(-Wall -Wextra -Wpedantic)
else()
# Disable ddl-interface warnings for STL from log4cxx code, because we are already
# Disable ddl-interface warnings for STL from log4cxx code, because we are already
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

dll.

@dirk-thomas
Copy link
Copy Markdown
Member

This patch might be responsible for this build failure: https://ci.ros2.org/view/nightly/job/nightly_linux_clang_libcxx/45/consoleFull#console-section-286 Please double check and address the problem asap. Thanks.

@nburek
Copy link
Copy Markdown
Contributor Author

nburek commented May 9, 2019

This patch might be responsible for this build failure: https://ci.ros2.org/view/nightly/job/nightly_linux_clang_libcxx/45/consoleFull#console-section-286 Please double check and address the problem asap. Thanks.

I started looking into this and it appears that the issue is that log4cxx isn't able to link when you compile with libcxx. I suspect this is because log4cxx is exposing std library objects in their API and these are different between the std lib that log4cxx was compiled with and libcxx.

@dirk-thomas
Copy link
Copy Markdown
Member

@emersonknapp FYI

@nburek
Copy link
Copy Markdown
Contributor Author

nburek commented May 9, 2019

I attempted to get log4cxx building with libc++ to see if we could do a build from source for this nightly CI job or switch to using a vendor package for log4cxx, but am running into issues getting the Apache Portable Runtime (APR) to compile with libc++.

After talking with @emersonknapp, we think that the quickest way to unblock this nightly CI is to swap the logging implementation using the "RCL_LOGGING_IMPLEMENTATION" environment variable so that it isn't trying to link against log4cxx. We can open a Github issue to track supporting libc++ for rcl_logging_log4cxx if that's something we decide is worth doing. @dirk-thomas Do you agree with this approach?

@dirk-thomas
Copy link
Copy Markdown
Member

Sounds fine with me.

@nburek
Copy link
Copy Markdown
Contributor Author

nburek commented May 10, 2019

I've started a PR to fix the nightly build: ros2/ci#291

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.

6 participants