ROS 2 rclcpp + rcl - kilted  kilted
ROS 2 C++ Client Library with ROS Client Library
Functions
logging_rosout.h File Reference
#include "rcl/allocator.h"
#include "rcl/error_handling.h"
#include "rcl/node.h"
#include "rcl/macros.h"
#include "rcl/types.h"
#include "rcl/visibility_control.h"
#include "rmw/qos_profiles.h"
Include dependency graph for logging_rosout.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_logging_rosout_init (const rcl_allocator_t *allocator)
 Initializes the rcl_logging_rosout features. More...
 
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_logging_rosout_fini (void)
 Uninitializes the rcl_logging_rosout features. More...
 
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_logging_rosout_init_publisher_for_node (rcl_node_t *node)
 Creates a rosout publisher for a node and registers it to be used by the logging system. More...
 
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_logging_rosout_fini_publisher_for_node (rcl_node_t *node)
 Deregisters a rosout publisher for a node and cleans up allocated resources. More...
 
RCL_PUBLIC void rcl_logging_rosout_output_handler (const rcutils_log_location_t *location, int severity, const char *name, rcutils_time_point_value_t timestamp, const char *format, va_list *args)
 The output handler outputs log messages to rosout topics. More...
 
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_logging_rosout_add_sublogger (const char *logger_name, const char *sublogger_name)
 Add a subordinate logger based on a logger. More...
 
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_logging_rosout_remove_sublogger (const char *logger_name, const char *sublogger_name)
 Remove a subordinate logger and cleans up allocated resources. More...
 

Function Documentation

◆ rcl_logging_rosout_add_sublogger()

RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_logging_rosout_add_sublogger ( const char *  logger_name,
const char *  sublogger_name 
)

Add a subordinate logger based on a logger.

Calling this will use the existing publisher of logger_name on a node to create an subordinate logger that will be used by the logging system to publish all log messages from that Node's logger.

If a subordinate logger already exists, it will NOT be created.

It is expected that after creating a subordinate logger with this function rcl_logging_rosout_remove_sublogger() will be called for the node to cleanup the subordinate logger while the publisher of logger_name is still valid.


Attribute Adherence
Allocates Memory Yes
Thread-Safe No
Uses Atomics No
Lock-Free Yes
Parameters
[in]logger_namea logger_name that has a corresponding rosout publisher on a node
[in]sublogger_namea sublogger name
Returns
RCL_RET_OK if the subordinate logger was created successfully, or
RCL_RET_INVALID_ARGUMENT if any arguments are invalid, or
RCL_RET_NOT_FOUND if the parent logger does not exist, or
RCL_RET_BAD_ALLOC if allocating memory failed, or
RCL_RET_ERROR if an unspecified error occurs.

Definition at line 398 of file logging_rosout.c.

References RCL_RET_INVALID_ARGUMENT, and RCL_RET_OK.

Referenced by rclcpp::Logger::get_child().

Here is the caller graph for this function:

◆ rcl_logging_rosout_fini()

RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_logging_rosout_fini ( void  )

Uninitializes the rcl_logging_rosout features.

Calling this will set the rcl_logging_rosout features into the an unitialized state that is functionally the same as before rcl_logging_rosout_init was called.


Attribute Adherence
Allocates Memory Yes
Thread-Safe No
Uses Atomics No
Lock-Free Yes
Returns
RCL_RET_OK if the rcl_logging_rosout feature was successfully unitialized, or
RCL_RET_ERROR if an unspecified error occurs.

Definition at line 176 of file logging_rosout.c.

References RCL_RET_OK.

Referenced by rcl_logging_fini().

Here is the caller graph for this function:

◆ rcl_logging_rosout_fini_publisher_for_node()

RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_logging_rosout_fini_publisher_for_node ( rcl_node_t node)

Deregisters a rosout publisher for a node and cleans up allocated resources.

Calling this for an rcl_node_t will destroy the rosout publisher on that node and remove it from the logging system so that no more Log messages are published to this function.


Attribute Adherence
Allocates Memory Yes
Thread-Safe No
Uses Atomics No
Lock-Free Yes
Parameters
[in]nodea valid rcl_node_t that the publisher will be created on
Returns
RCL_RET_OK if the logging publisher was finalized successfully, or
RCL_RET_NODE_INVALID if any arguments are invalid, or
RCL_RET_BAD_ALLOC if allocating memory failed, or
RCL_RET_ERROR if an unspecified error occurs.

Definition at line 271 of file logging_rosout.c.

References rcl_node_get_logger_name(), rcl_publisher_fini(), RCL_RET_ERROR, RCL_RET_NODE_INVALID, and RCL_RET_OK.

Here is the call graph for this function:

◆ rcl_logging_rosout_init()

RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_logging_rosout_init ( const rcl_allocator_t allocator)

Initializes the rcl_logging_rosout features.

Calling this will initialize the rcl_logging_rosout features. This function must be called before any other rcl_logging_rosout_* functions can be called.


Attribute Adherence
Allocates Memory Yes
Thread-Safe No
Uses Atomics No
Lock-Free Yes
Parameters
[in]allocatorThe allocator used for metadata related to the rcl_logging_rosout features
Returns
RCL_RET_OK if the rcl_logging_rosout features are successfully initialized, or
RCL_RET_INVALID_ARGUMENT if any arguments are invalid, or
RCL_RET_BAD_ALLOC if allocating memory failed, or
RCL_RET_ERROR if an unspecified error occurs.

Definition at line 56 of file logging_rosout.c.

References RCL_RET_INVALID_ARGUMENT, and RCL_RET_OK.

Referenced by rcl_logging_configure_with_output_handler().

Here is the caller graph for this function:

◆ rcl_logging_rosout_init_publisher_for_node()

RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_logging_rosout_init_publisher_for_node ( rcl_node_t node)

Creates a rosout publisher for a node and registers it to be used by the logging system.

Calling this for an rcl_node_t will create a new publisher on that node that will be used by the logging system to publish all log messages from that Node's logger.

If a publisher already exists for this node then a new publisher will NOT be created.

It is expected that after creating a rosout publisher with this function rcl_logging_destroy_rosout_publisher_for_node() will be called for the node to cleanup the publisher while the Node is still valid.


Attribute Adherence
Allocates Memory Yes
Thread-Safe No
Uses Atomics No
Lock-Free Yes
Parameters
[in]nodea valid rcl_node_t that the publisher will be created on
Returns
RCL_RET_OK if the logging publisher was created successfully, or
RCL_RET_NODE_INVALID if the argument is invalid, or
RCL_RET_BAD_ALLOC if allocating memory failed, or
RCL_RET_ERROR if an unspecified error occurs.

Definition at line 202 of file logging_rosout.c.

References rcl_node_options_s::allocator, rcl_publisher_options_s::allocator, rcl_publisher_options_s::qos, rcl_get_zero_initialized_publisher(), rcl_node_get_logger_name(), rcl_node_get_name(), rcl_node_get_options(), rcl_publisher_fini(), rcl_publisher_get_default_options(), rcl_publisher_init(), RCL_RET_ERROR, RCL_RET_NODE_INVALID, RCL_RET_OK, and rcl_node_options_s::rosout_qos.

Referenced by rclcpp::node_interfaces::NodeBase::NodeBase().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rcl_logging_rosout_output_handler()

RCL_PUBLIC void rcl_logging_rosout_output_handler ( const rcutils_log_location_t *  location,
int  severity,
const char *  name,
rcutils_time_point_value_t  timestamp,
const char *  format,
va_list *  args 
)

The output handler outputs log messages to rosout topics.

When called with a logger name and log message this function will attempt to find a rosout publisher correlated with the logger name and publish a Log message out via that publisher. If there is no publisher directly correlated with the logger then nothing will be done.

This function is meant to be registered with the logging functions for rcutils, and shouldn't be used outside of that context. Additionally, arguments like args should be non-null and properly initialized otherwise it is undefined behavior.


Attribute Adherence
Allocates Memory Yes
Thread-Safe No
Uses Atomics No
Lock-Free Yes
Parameters
[in]locationThe pointer to the location struct or NULL
[in]severityThe severity level
[in]nameThe name of the logger, must be null terminated c string
[in]timestampThe timestamp for when the log message was made
[in]formatThe list of arguments to insert into the formatted log message
[in]argsargument for the string format

Definition at line 313 of file logging_rosout.c.

References RCL_NS_TO_S, rcl_publish(), RCL_RET_OK, and RCL_S_TO_NS.

Referenced by rcl_logging_configure_with_output_handler().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rcl_logging_rosout_remove_sublogger()

RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_logging_rosout_remove_sublogger ( const char *  logger_name,
const char *  sublogger_name 
)

Remove a subordinate logger and cleans up allocated resources.

Calling this will destroy the subordinate logger based on logger_name+RCUTILS_LOGGING_SEPARATOR_STRING+sublogger_name on that node and remove it from the logging system so that no more Log messages are published to this function.


Attribute Adherence
Allocates Memory Yes
Thread-Safe No
Uses Atomics No
Lock-Free Yes
Parameters
[in]logger_namea logger_name that has a corresponding rosout publisher on a node
[in]sublogger_namea sublogger name
Returns
RCL_RET_OK if the subordinate logger was finalized successfully, or
RCL_RET_INVALID_ARGUMENT if any arguments are invalid, or
RCL_RET_NOT_FOUND if the sublogger does not exist, or
RCL_RET_BAD_ALLOC if allocating memory failed, or
RCL_RET_ERROR if an unspecified error occurs.

Definition at line 483 of file logging_rosout.c.

References RCL_RET_INVALID_ARGUMENT, RCL_RET_NOT_FOUND, and RCL_RET_OK.

Referenced by rclcpp::Logger::get_child().

Here is the caller graph for this function: