-
Notifications
You must be signed in to change notification settings - Fork 331
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
Add demo for logging + logger config #194
Conversation
790d9db
to
d6a0b66
Compare
13e7e91
to
916b226
Compare
93e978e
to
dde08f5
Compare
Ready for review. This demo adds a node using log calls that configures its logger level programmatically. There's also a component that responds to service requests for changes to the logger severity. This can be added to component-based systems to enable external logger configuration at runtime. I've tried to make it clear in the readme that this isn't the long-term plan for runtime configuration, just something that people might find useful. If we think it sends the wrong message we can just flat out say we only support programmatic configuration instead. The readme has the usage: https://github.com/ros2/demos/pull/194/files#diff-599b8049677d7c1e29b69de5f3aef287 |
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 looked only at the code and will review the readme and try the instructions in the next pass.
logging_demo/CMakeLists.txt
Outdated
endif() | ||
|
||
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||
add_compile_options(-Wall -Wextra) |
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.
Nit: Adding a comment here explaining why we cant use pedantic like the other repos will be useful for book keeping
logging_demo/CMakeLists.txt
Outdated
macro(tests) | ||
set(LOGGING_DEMO_MAIN_EXECUTABLE $<TARGET_FILE:logging_demo_main>) | ||
set(EXPECTED_OUTPUT_LOGGING_DEMO_MAIN_DEFAULT_SEVERITY "${CMAKE_CURRENT_SOURCE_DIR}/test/logging_demo_main_default_severity") | ||
set(EXPECTED_OUTPUT_LOGGING_DEMO_MAIN_DEBUG_SEVERITY "${CMAKE_CURRENT_SOURCE_DIR}/test/logging_demo_main_debug_severity") |
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.
Nit: these two lines look long
@@ -0,0 +1,37 @@ | |||
// Copyright 2016 Open Source Robotics Foundation, Inc. |
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.
Nit: 2017
#define LOGGING_DEMO__LOGGER_CONFIG_COMPONENT_HPP_ | ||
|
||
#include "logging_demo/visibility_control.h" | ||
#include "logging_demo/srv/config_logger.hpp" |
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.
Nit: include order
logging_demo/package.xml
Outdated
<package format="2"> | ||
<name>logging_demo</name> | ||
<version>0.0.3</version> | ||
<description>Examples for composing multiple nodes in a single process.</description> |
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.
The description should be updated, maintainer tag as well
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.
do you think it's alright to start this at v0.0.3? figured it's easier for when we bump them all?
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.
yup! will make @nuclearsandwich's blooming easier
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.
All packages in the same repository need to have the same version, so not keeping it in line with the other package's version would actually make it impossible to release :)
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.
ah! ok then it stays!
logging_demo/CMakeLists.txt
Outdated
|
||
configure_file( | ||
test/test_logging_demo.py.in | ||
test_logging_demo${target_suffix}.py.genexp |
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.
Out of curiosity what does genexp stands for here?
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.
that it'll be the input to the generate command in the following line to have its generator expressions (above) expanded
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.
ahhh thanks I couldnt figure out what genexp was suppose to abbreviate
} | ||
} | ||
|
||
bool divides_into_twelve(size_t val, std::string logger_name) |
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.
does this mean that this returns that the value is a divider of 12 ?
(maybe that's my english + math vocabulary here but I had to check the code to see what divides_into_twelve
mean). I would have expected this to return (val % 12) == 0
aka is_multiple_of_twelve
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.
yeah it means is_divisor_of_twelve, I'll update the name
launch(name, [executable], output_file) | ||
|
||
|
||
def launch(name, cmd, output_file, additional_processes=None): |
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.
this could default to []
and avoid adding the logic (additional_processes or [])
below
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.
We try to avoid mutable defaults in general
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.
fair point, forgot about that 👍
|
||
assert rc == 0, \ | ||
"The launch file failed with exit code '" + str(rc) + "'. " \ | ||
'Maybe the client did not receive any messages?' |
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.
Not sure what the failure criteria is here but it looks like the assert message could use an update
@@ -0,0 +1 @@ | |||
\[DEBUG\] \[logger_usage_demo\]: Count divides into 12 \(function evaluated to true\) |
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.
Doest this need to be a regex? it seems like it could be a string to match like the file below
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.
if it's a txt it can't have any messages printed before this one gets matched or it fails
logging_demo/package.xml
Outdated
@@ -0,0 +1,36 @@ | |||
<?xml version="1.0"?> | |||
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?> | |||
<package format="2"> |
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.
Now that ros2/common_interfaces#45 and friends have been merged this should be updated to format3 and be declared as part of the rosidl_interface_packages
group
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.
will do
This reverts commit 47305c0.
still looking for reviews on this if anyone has a chance, but it's lower priority overall since it's just a demo (the changes to the core required for this have been merged already) |
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.
lgtm, though I think it might need some touch ups to compile again after ros2/rcutils#82
logging_demo/README.md
Outdated
@@ -0,0 +1,75 @@ | |||
# Logging and logger configuration | |||
|
|||
See [the logging page]() for details on available functionality. |
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.
Needs a link?
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.
yeah I'll add it when I move it to the wiki 👍 sorry it wasn't clear that this is temporary.
logging_demo/logging_wiki.md
Outdated
|
||
In C++: | ||
``` | ||
rcutils_logging_set_logger_severity_threshold("logger_name", RCUTILS_LOG_SEVERITY_DEBUG); |
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.
Are these names still right?
} | ||
|
||
// TODO(dhood): allow configuration through rclcpp | ||
auto ret = rcutils_logging_set_logger_severity_threshold( |
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.
These changed in ros2/rcutils#82 didn't they?
: Node("logger_config") | ||
{ | ||
auto handle_logger_config_req = | ||
[this]( |
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.
You only ever appear to use the get_name()
of this
, maybe just capture the name?
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.
Or make it a method like you did elsewhere in this pr.
@nuclearsandwich apologies for forgetting to tag you earlier but this ( |
@mikaelarguedas (build cop) I've seen the instability with connext and will fix |
btw the wiki page is at https://github.com/ros2/ros2/wiki/Logging-and-logger-configuration |
Usage:
The LoggerConfig component can be dropped into a running (composition-api-based) system to get config access to the loggers of the process