Skip to content

Add per composable node log_level support#531

Open
penww wants to merge 1 commit into
ros2:rollingfrom
penww:rolling
Open

Add per composable node log_level support#531
penww wants to merge 1 commit into
ros2:rollingfrom
penww:rolling

Conversation

@penww
Copy link
Copy Markdown

@penww penww commented Apr 9, 2026

Description

Fixes # (ros2/rclcpp#3091)

Is this user-facing behavior change?

No, this change add new parameter for ComposableNode, not affect the existing functions.

Did you use Generative AI?

Yes, partially with Claude Sonnet 4.6.

Additional Information

Example for per component log level feature enabled:

def generate_launch_description():
    return LaunchDescription([ComposableNodeContainer(
        name='component_demo_container',
        namespace='',
        package='rclcpp_components',
        executable='component_container',
        composable_node_descriptions=[
            ComposableNode(
                package='<PKG>',
                plugin='<PLUGIN>',
                log_level='DEBUG',  # component log level
            ),
        ],
        arguments=['--ros-args', '--log-level', 'INFO'],  # container log level
    )])

Related PR: ros2/rclcpp#3092, ros2/ros2cli#1212

Signed-off-by: Peng Wang <penwang@qti.qualcomm.com>
Copy link
Copy Markdown
Contributor

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

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

test would be ideal too.

'ERROR': rcl_interfaces.msg.Log.ERROR,
'FATAL': rcl_interfaces.msg.Log.FATAL,
}
request.log_level = log_level_map.get(log_level_str, 0)
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.

this fallback is NOT great for the user application. if user sets typos log_level='debig', it silently sets it to UNSET and the user will not be notified configuration gone wrong. i think that this behavior is actually worse then raising the exception, what do you think? i say, we should enforce the check and return error would be better. and again this should be done with rclpy get_logging_severity_from_string?

log_level_str = perform_substitutions(
context, composable_node_description.log_level).upper()
log_level_map = {
'DEBUG': rcl_interfaces.msg.Log.DEBUG,
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.

should be rcl_interfaces.msg.LoggerLevel.

'DEBUG': rcl_interfaces.msg.Log.DEBUG,
'INFO': rcl_interfaces.msg.Log.INFO,
'WARN': rcl_interfaces.msg.Log.WARN,
'WARNING': rcl_interfaces.msg.Log.WARN,
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.

docstring does not mention about this string though... we should add it to the help docstring?

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.

2 participants