From 925c3b1fc09530ce894d6a83109d69a1ed857dc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Hern=C3=A1ndez=20Cordero?= Date: Tue, 5 Nov 2024 12:51:33 +0100 Subject: [PATCH] use updated function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Alejandro Hernández Cordero --- rmw_zenoh_cpp/src/rmw_init.cpp | 21 +++------------------ rmw_zenoh_cpp/src/zenohd/main.cpp | 21 +++------------------ 2 files changed, 6 insertions(+), 36 deletions(-) diff --git a/rmw_zenoh_cpp/src/rmw_init.cpp b/rmw_zenoh_cpp/src/rmw_init.cpp index 91302f7b..ebaf0070 100644 --- a/rmw_zenoh_cpp/src/rmw_init.cpp +++ b/rmw_zenoh_cpp/src/rmw_init.cpp @@ -89,24 +89,9 @@ rmw_init(const rmw_init_options_t * options, rmw_context_t * context) // If not already defined, set the logging environment variable for Zenoh sessions // to warning level by default. - // TODO(Yadunund): Switch to rcutils_get_env once it supports not overwriting values. - - const char * value; - const char * error_message = rcutils_get_env(ZENOH_LOG_ENV_VAR_STR, &value); - if (error_message != NULL) { - RMW_SET_ERROR_MSG_WITH_FORMAT_STRING( - "Error configuring Zenoh logging. Unable to get %s environment variable: %s", - ZENOH_LOG_ENV_VAR_STR, - error_message); - return RMW_RET_ERROR; - } - if (value == nullptr) { - if (!rcutils_set_env(ZENOH_LOG_ENV_VAR_STR, ZENOH_LOG_WARN_LEVEL_STR)) { - RMW_SET_ERROR_MSG_WITH_FORMAT_STRING( - "Error configuring Zenoh logging. Unable to set %s environment variable.", - ZENOH_LOG_ENV_VAR_STR); - return RMW_RET_ERROR; - } + if (!rcutils_set_env_overwrite(ZENOH_LOG_ENV_VAR_STR, ZENOH_LOG_WARN_LEVEL_STR, 0)) { + RMW_SET_ERROR_MSG("Error configuring Zenoh logging."); + return 1; } // Create the context impl. diff --git a/rmw_zenoh_cpp/src/zenohd/main.cpp b/rmw_zenoh_cpp/src/zenohd/main.cpp index c5812a96..74205c99 100644 --- a/rmw_zenoh_cpp/src/zenohd/main.cpp +++ b/rmw_zenoh_cpp/src/zenohd/main.cpp @@ -63,24 +63,9 @@ int main(int argc, char ** argv) // If not already defined, set the logging environment variable for Zenoh router // to info level by default. - // TODO(Yadunund): Switch to rcutils_get_env once it supports not overwriting values. - - const char * value; - const char * error_message = rcutils_get_env(ZENOH_LOG_ENV_VAR_STR, &value); - if (error_message != NULL) { - RMW_SET_ERROR_MSG_WITH_FORMAT_STRING( - "Error configuring Zenoh logging. Unable to get %s environment variable: %s", - ZENOH_LOG_ENV_VAR_STR, - error_message); - return RMW_RET_ERROR; - } - if (value == nullptr) { - if (!rcutils_set_env(ZENOH_LOG_ENV_VAR_STR, ZENOH_LOG_INFO_LEVEL_STR)) { - RMW_SET_ERROR_MSG_WITH_FORMAT_STRING( - "Error configuring Zenoh logging. Unable to set %s environment variable.", - ZENOH_LOG_ENV_VAR_STR); - return RMW_RET_ERROR; - } + if (!rcutils_set_env_overwrite(ZENOH_LOG_ENV_VAR_STR, ZENOH_LOG_INFO_LEVEL_STR, 0)) { + RMW_SET_ERROR_MSG("Error configuring Zenoh logging."); + return 1; } // Initialize the zenoh configuration for the router.