Skip to content

Commit

Permalink
use parent logger (ros2#921)
Browse files Browse the repository at this point in the history
* use parent logger

Signed-off-by: Chen Lihui <Lihui.Chen@sony.com>
---------

Signed-off-by: Chen Lihui <Lihui.Chen@sony.com>
Signed-off-by: Chen Lihui <lihui.chen@sony.com>
Co-authored-by: Tomoya.Fujita <Tomoya.Fujita@sony.com>
  • Loading branch information
2 people authored and danthony06 committed Jun 14, 2023
1 parent 06a852d commit bc564bb
Show file tree
Hide file tree
Showing 3 changed files with 516 additions and 37 deletions.
63 changes: 63 additions & 0 deletions rcl/include/rcl/logging_rosout.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,69 @@ rcl_logging_rosout_output_handler(
const char * format,
va_list * args);

/// 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.
*
*
* <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | Yes
* Thread-Safe | No
* Uses Atomics | No
* Lock-Free | Yes
*
* \param[in] logger_name a logger_name that has a corresponding rosout publisher on a node
* \param[in] sublogger_name a sublogger name
* \return #RCL_RET_OK if the subordinate logger was created successfully, or
* \return #RCL_RET_INVALID_ARGUMENT if any arguments are invalid, or
* \return #RCL_RET_SUBLOGGER_ALREADY_EXIST if the subordinate logger already exists, or
* \return #RCL_RET_BAD_ALLOC if allocating memory failed, or
* \return #RCL_RET_ERROR if an unspecified error occurs.
*/
RCL_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_logging_rosout_add_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.
*
*
* <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | Yes
* Thread-Safe | No
* Uses Atomics | No
* Lock-Free | Yes
*
* \param[in] logger_name a logger_name that has a corresponding rosout publisher on a node
* \param[in] sublogger_name a sublogger name
* \return #RCL_RET_OK if the subordinate logger was finalized successfully, or
* \return #RCL_RET_INVALID_ARGUMENT if any arguments are invalid, or
* \return #RCL_RET_BAD_ALLOC if allocating memory failed, or
* \return #RCL_RET_ERROR if an unspecified error occurs.
*/
RCL_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_logging_rosout_remove_sublogger(
const char * logger_name, const char * sublogger_name);

#ifdef __cplusplus
}
#endif
Expand Down
Loading

0 comments on commit bc564bb

Please sign in to comment.