Conversation
|
Looks reasonable to me so far. It could either be its own module or part of the existing one. I don't think it needs to be in a separate package. Is there any downside to initializing it automatically? |
dirk-thomas
left a comment
There was a problem hiding this comment.
A separate library within the same package looks good to me. We can always change it later if we see a reason to do so.
rclpy/CMakeLists.txt
Outdated
| target_include_directories(${library_name} | ||
| PUBLIC | ||
| ${PythonExtra_INCLUDE_DIRS} | ||
| ) |
There was a problem hiding this comment.
Instead of duplicating the logic to update the target with various information this should be moved into a function for reuse.
rclpy/src/rclpy/_rclpy_logging.c
Outdated
| static struct PyModuleDef _rclpy_logging_module = { | ||
| PyModuleDef_HEAD_INIT, | ||
| "_rclpy_logging", | ||
| "_rclpy_logging_doc", |
There was a problem hiding this comment.
Instead of a dummy this should be NULL or a actual docstring.
rclpy/test/test_logging.py
Outdated
| def setUpClass(cls): | ||
| rclpy.logging.initialize() | ||
|
|
||
| def test_set_get_severity_threshold(self): |
There was a problem hiding this comment.
Nitpick about the name: Use *_get_set_* (since that is the order used in the test) or just test_severity_threshold.
Just set and get severity level at the moment
This should be consistent with the C implementation of features in rcutils
In the C implementation in rcutils, all features are static.
@dirk-thomas mentioned someone might want to import the module, use a custom logging configuration, and then initialise. If we always initialise then the custom initialisation won't have an effect.
Also, the object as the context key wasn't unique so go back to using pickle
In anticipation of the global threshold being replaced by ones specific to each logger.
It was originally templated to reduce the coupling between the python enum and the rcutils C enum, but the names were still coupled anyway.
Add an option to return the result of the log condition
|
To fix Another issue on Windows was that, surprisingly to me, the Most of this was done in 6c6917f; if there's a cleaner way that avoids lower casing everything I'm interested. Example usage on windows is: and on linux: |
|
there are still a few outstanding comments that I will respond to tomorrow |
dirk-thomas
left a comment
There was a problem hiding this comment.
Regarding inspect.getabsfile(): since this function is not publically documented I was wondering if another approach to get the same information has the same case problem on Windows. Have you tried os.path.abspath(inspect.getframeinfo(frame).filename) instead?
rclpy/rclpy/impl/rcutils_logger.py
Outdated
| return frame | ||
|
|
||
|
|
||
| class CallerId: |
There was a problem hiding this comment.
Maybe the class could use __slots__ if it is never intended to be extended with additional attributes.
That would also make the implementation of __hash__ and __eq__ easier by just iterating the slots and avoiding the repetition of the member names.
rclpy/rclpy/impl/rcutils_logger.py
Outdated
| if not frame: | ||
| frame = _find_caller(inspect.currentframe()) | ||
| self.function_name = frame.f_code.co_name | ||
| self.file_name = _normalize_path(inspect.getabsfile(frame)) |
There was a problem hiding this comment.
For file_name I would only expect the name of the file but not its full path. Maybe rename to file_path?
rclpy/rclpy/impl/rcutils_logger.py
Outdated
| # This has to be done from within a function to avoid cyclic module imports. | ||
| import rclpy.logging | ||
| # Extend the list to preserve any filenames that may have been added by third parties. | ||
| # Note: the call to `abspath` will also resolve mixed slashes that can result on Windows. |
There was a problem hiding this comment.
Using realpath will also resolve symlinks and therefore ensure that they compare equal even if one is a symlink of the other.
There was a problem hiding this comment.
thanks! I changed it in c4ae7a7 but only for the _find_caller function. the file path that will displayed in the logging call is still using abspath because I thought that would be more what users are expecting (but maybe not)
This reverts commit 5cf9c54.
…ut while rebasing)
Leave the final file path that gets displayed as-is for usability.
Hard-code the filter options for now
|
Indeed using Update on the aforementioned todos:
With that, I'll put this back in review (I think I've addressed the comments to date, LMK if I missed something) |
…tests-to-test-logger Fixed test that failed without ROS_PACKAGE_PATH being set, and add test_log
connects to #103
Could I get some feedback on the direction this is going in? I add
loggingas an additional module of therclpypackage but it might belong in its own package or in therclpymodule itself.