Draft: Document internals of logging system#2028
Draft: Document internals of logging system#2028tylerjw wants to merge 1 commit intoros2:rollingfrom
Conversation
ba0c61e to
3ab8894
Compare
|
Here are warnings that I get when I build locally. I need to read up on rst syntax and fix these: |
3ab8894 to
1ee4ffe
Compare
Signed-off-by: Tyler Weaver <tylerjw@gmail.com>
1ee4ffe to
2f50b88
Compare
| There is currently only one external library interface defined and that is ``rcl_logging_spdlog``. | ||
| The external-lib implementation is set during the CMake configure step of the package ``rcl``. | ||
| It can be overridden with the variable ``RCL_LOGGING_IMPLEMENTATION``. | ||
| The ``rcl_logging`` README says there is a ``rcl_logging_log4cxx`` implementation, however that does not appear to exist yet. |
There was a problem hiding this comment.
This was supported previously and got removed
There was a problem hiding this comment.
Maybe another PR can be created updating the rcl_logging README, or at least an issue opened?
There was a problem hiding this comment.
| The ``rcl_logging`` README says there is a ``rcl_logging_log4cxx`` implementation, however that does not appear to exist yet. |
| Log files | ||
| --------- | ||
|
|
||
| Log output files written to a directory that defaults to ``~/.ros/log`` but can be changed through enviroment variables. The filenames follow this pattern: | ||
|
|
||
| ``<exe>_<pid>_<milliseconds-since-epoch>.log`` | ||
|
|
||
| These are created per operating system process. | ||
| The external lib logging using ``spdlog`` is what writes these files in the current implementation. |
There was a problem hiding this comment.
Should we move this part to https://github.com/ros2/ros2_documentation/blob/rolling/source/Tutorials/Logging-and-logger-configuration.rst?, I see there's a section about Logging directory configuration
| Logging from a Python ROS Node | ||
| ------------------------------ | ||
|
|
||
| The Python interfaces are built on top of ``rclcpp`` and therefore share the same functionality. |
There was a problem hiding this comment.
This is definitely not true; rclcpp and rclpy are siblings. It may be true that rclpy depends on rcl, though I'm not sure of that; Python has robust logging facilities of its own, we may be using those instead.
clalancette
left a comment
There was a problem hiding this comment.
This is a good start to this documentation.
That said, adding this information to this document mixes up the user-facing portion of the Concept with the technical details on how things are implemented. I might suggest that we split this into two documents; the current Concepts/About-Logging.rst talks about the logging system from the users POV (with some additional notes from what you've written below), and then a new Concepts/Logging-Implementation.rst which describes how it is implemented. What do you think?
There was a problem hiding this comment.
This looks like great content to add. I agree with @clalancette about splitting it up.
Some general feedback, that may be more from it being a "Draft" state is that there are several times that things are implicitly referenced (e.g., "This is necessary because..." and "One implication of this is..."). It is often not clear to me what "this" is referring to. It would be good to be more specific, even if you feel it is a bit needlessly wordy.
| Compiling out logging | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
|
||
| To compile wihtout logging set ``RCLCPP_LOGGING_ENABLED=0`` and ``RCLCPP_LOG_MIN_SEVERITY=RCLCPP_LOG_MIN_SEVERITY_NONE``. |
There was a problem hiding this comment.
| To compile wihtout logging set ``RCLCPP_LOGGING_ENABLED=0`` and ``RCLCPP_LOG_MIN_SEVERITY=RCLCPP_LOG_MIN_SEVERITY_NONE``. | |
| To compile without logging, set ``RCLCPP_LOGGING_ENABLED=0`` and ``RCLCPP_LOG_MIN_SEVERITY=RCLCPP_LOG_MIN_SEVERITY_NONE``. |
|
|
||
| One implication of this is that in any ROS process based on ``rclcpp`` it is single-threaded during logging. | ||
| To combat the performance implications of this you can use throttling. | ||
| This is necessary because the logging system writes to file streams (stderr, stdout, normal files) which cannot be done from multiple threads in a sane way. | ||
| A possible technique to log from a thread you need to be lock-free would be to use internal queues to send data to another thread that then logs your data. |
There was a problem hiding this comment.
| One implication of this is that in any ROS process based on ``rclcpp`` it is single-threaded during logging. | |
| To combat the performance implications of this you can use throttling. | |
| This is necessary because the logging system writes to file streams (stderr, stdout, normal files) which cannot be done from multiple threads in a sane way. | |
| A possible technique to log from a thread you need to be lock-free would be to use internal queues to send data to another thread that then logs your data. | |
| One implication of this is that in any ROS process based on ``rclcpp`` is single-threaded during logging. | |
| This is necessary because the logging system writes to file streams (stderr, stdout, normal files) which cannot easily be done from multiple threads. |
I think this paragraph can have some explanation cut and can be combined with the above paragraph.
Maybe add the cutout segments as notes, for example.
|
|
||
| To compile wihtout logging set ``RCLCPP_LOGGING_ENABLED=0`` and ``RCLCPP_LOG_MIN_SEVERITY=RCLCPP_LOG_MIN_SEVERITY_NONE``. | ||
|
|
||
| Will this only work with a source build of ros2 or can this be done per project that depends on ros2? |
There was a problem hiding this comment.
| Will this only work with a source build of ros2 or can this be done per project that depends on ros2? | |
| Will this only work with a source build of ROS 2, or can this be done per project that depends on ROS 2? |
We prefer "ROS 2."
| rclcpp ``Logger`` class | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
|
||
| Stores a name string. |
There was a problem hiding this comment.
| Stores a name string. | |
| The ``Logger`` class stores a name string, which is used to identify the logger. |
| ``RCLCPP`` macros | ||
| ^^^^^^^^^^^^^^^^^ | ||
|
|
||
| Defined by generated header in rclcpp (rclcpp/resource/logging.hpp.em). |
There was a problem hiding this comment.
It would be nice to make the first lines of sections full sentences, or to format them differently, in a way that clearly indicates this is a definition.
| rosout logging | ||
| ^^^^^^^^^^^^^^ | ||
|
|
||
| Publishes a ``rcl_interfaces::Log`` message to the topic /node-name/rosout. |
There was a problem hiding this comment.
| Publishes a ``rcl_interfaces::Log`` message to the topic /node-name/rosout. | |
| Publishes a ``rcl_interfaces::Log`` message to the topic ``/node-name/rosout``. |
| There is currently only one external library interface defined and that is ``rcl_logging_spdlog``. | ||
| The external-lib implementation is set during the CMake configure step of the package ``rcl``. | ||
| It can be overridden with the variable ``RCL_LOGGING_IMPLEMENTATION``. | ||
| The ``rcl_logging`` README says there is a ``rcl_logging_log4cxx`` implementation, however that does not appear to exist yet. |
There was a problem hiding this comment.
Maybe another PR can be created updating the rcl_logging README, or at least an issue opened?
| There is currently only one external library interface defined and that is ``rcl_logging_spdlog``. | ||
| The external-lib implementation is set during the CMake configure step of the package ``rcl``. | ||
| It can be overridden with the variable ``RCL_LOGGING_IMPLEMENTATION``. | ||
| The ``rcl_logging`` README says there is a ``rcl_logging_log4cxx`` implementation, however that does not appear to exist yet. |
There was a problem hiding this comment.
| The ``rcl_logging`` README says there is a ``rcl_logging_log4cxx`` implementation, however that does not appear to exist yet. |
| RCUTILS internals | ||
| ----------------- | ||
|
|
||
| ``rcutils`` contains macros and functions that define some of the non-ros low-level logging behavior in C. |
There was a problem hiding this comment.
| ``rcutils`` contains macros and functions that define some of the non-ros low-level logging behavior in C. | |
| ``rcutils`` contains macros and functions that define some of the non-ROS low-level logging behavior in C. |
| - Don't use colours. | ||
|
|
||
| If it is unset, colors are used depending on if the target stream is a terminal or not. | ||
| See `isatty` documentation. |
There was a problem hiding this comment.
It would be nice to add a link here.
|
Closing in favor of the just merged #3025. It doesn't have quite as much detail as this one has, but I think it is good enough for the end-user to understand what is going on. We should probably have a separate design document somewhere about the real internals of the logging subsystem, but that would probably live in https://github.com/ros-infrastructure/rep . |
Signed-off-by: Tyler Weaver tylerjw@gmail.com
Closes #2026
@JafarAbdi would you mind reviewing this for correctness and completeness? You recently had to trace this code to create your PR against it for file based configuration.
@clalancette here is my initial attempt at documenting this. Would you mind reviewing this for structure, organization, and completeness from a high level? I'm unsure how to organize this documentation within the existing page(s) describing the logging system.