Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions rcl/include/rcl/logging_external_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
#include "rcl/types.h"
#include "rcl/visibility_control.h"

#ifdef __cplusplus
extern "C" {
#endif

/// Initialize the external logging library.
/**
* \param[in] config_file The location of a config file that the external
Expand Down Expand Up @@ -78,6 +82,11 @@ rcl_logging_external_log(int severity, const char * name, const char * msg);
* \return RCL_RET_ERROR if an unspecified error occurs.
*/
RCL_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t rcl_logging_external_set_logger_level(const char * name, int level);

#ifdef __cplusplus
}
#endif

#endif // RCL__LOGGING_EXTERNAL_INTERFACE_H_
6 changes: 1 addition & 5 deletions rcl/include/rcl/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,8 @@ extern "C"
{
#endif

#ifndef _WIN32
/// Ignored return values of functions with this macro will emit a warning.
# define RCL_WARN_UNUSED __attribute__((warn_unused_result))
#else
# define RCL_WARN_UNUSED _Check_return_
#endif
#define RCL_WARN_UNUSED RCUTILS_WARN_UNUSED
Comment thread
dirk-thomas marked this conversation as resolved.

#define RCL_UNUSED(x) (void)(x)

Expand Down
8 changes: 7 additions & 1 deletion rcl/src/rcl/logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,13 @@ rcl_logging_configure(const rcl_arguments_t * global_args, const rcl_allocator_t
if (g_rcl_logging_ext_lib_enabled) {
status = rcl_logging_external_initialize(config_file, g_logging_allocator);
if (RCL_RET_OK == status) {
rcl_logging_external_set_logger_level(NULL, default_level);
// TODO(dirk-thomas) the return value should be typed and compared to
// constants instead of zero

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

While this mismatch is unfortunately it is better then not enforcing to check the return value.

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.

@dirk-thomas mind to explain? rcl_logging_external_set_logger_level() returns an rcl_ret_t value.

int logging_status = rcl_logging_external_set_logger_level(
NULL, default_level);
if (logging_status != 0) {
status = RCL_RET_ERROR;
}
g_rcl_logging_out_handlers[g_rcl_logging_num_out_handlers++] =
rcl_logging_ext_lib_output_handler;
}
Expand Down