Skip to content

Commit

Permalink
Implement rmw_set_log_severity
Browse files Browse the repository at this point in the history
Signed-off-by: Yadunund <[email protected]>
  • Loading branch information
Yadunund committed Jul 1, 2024
1 parent afe1378 commit 73af670
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
4 changes: 2 additions & 2 deletions rmw_zenoh_cpp/src/detail/logging_macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
// which can lead to deadlocks in rmw_zenoh especially when multiple threads
// invoke GraphCache::parse_put() and GraphCache::parse_del() functions.
// See https://github.com/ros2/rmw_zenoh/issues/182 for more details.
// Note: Consider adding a set_rmw_log_level() API to rmw which can override the
// default log level at the RMW layer.
#define RMW_ZENOH_LOG_DEBUG_NAMED(...) {rmw_zenoh_cpp::Logger::get().log_named( \
RCUTILS_LOG_SEVERITY_DEBUG, __VA_ARGS__);}
#define RMW_ZENOH_LOG_ERROR_NAMED(...) {rmw_zenoh_cpp::Logger::get().log_named( \
RCUTILS_LOG_SEVERITY_ERROR, __VA_ARGS__);}
#define RMW_ZENOH_LOG_FATAL_NAMED(...) {rmw_zenoh_cpp::Logger::get().log_named( \
RCUTILS_LOG_SEVERITY_FATAL, __VA_ARGS__);}
#define RMW_ZENOH_LOG_INFO_NAMED(...) {rmw_zenoh_cpp::Logger::get().log_named( \
RCUTILS_LOG_SEVERITY_INFO, __VA_ARGS__);}
#define RMW_ZENOH_LOG_WARN_NAMED(...) {rmw_zenoh_cpp::Logger::get().log_named( \
Expand Down
22 changes: 20 additions & 2 deletions rmw_zenoh_cpp/src/rmw_zenoh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3874,8 +3874,26 @@ rmw_service_server_is_available(
rmw_ret_t
rmw_set_log_severity(rmw_log_severity_t severity)
{
static_cast<void>(severity);
return RMW_RET_UNSUPPORTED;
switch (severity) {
case RMW_LOG_SEVERITY_DEBUG:
rmw_zenoh_cpp::Logger::get().set_log_level(RCUTILS_LOG_SEVERITY_DEBUG);
break;
case RMW_LOG_SEVERITY_INFO:
rmw_zenoh_cpp::Logger::get().set_log_level(RCUTILS_LOG_SEVERITY_INFO);
break;
case RMW_LOG_SEVERITY_WARN:
rmw_zenoh_cpp::Logger::get().set_log_level(RCUTILS_LOG_SEVERITY_WARN);
break;
case RMW_LOG_SEVERITY_ERROR:
rmw_zenoh_cpp::Logger::get().set_log_level(RCUTILS_LOG_SEVERITY_ERROR);
break;
case RMW_LOG_SEVERITY_FATAL:
rmw_zenoh_cpp::Logger::get().set_log_level(RCUTILS_LOG_SEVERITY_FATAL);
break;
default:
return RMW_RET_UNSUPPORTED;
}
return RMW_RET_OK;
}

//==============================================================================
Expand Down

0 comments on commit 73af670

Please sign in to comment.