Skip to content

Commit

Permalink
use updated function
Browse files Browse the repository at this point in the history
Signed-off-by: Alejandro Hernández Cordero <[email protected]>
  • Loading branch information
ahcorde committed Nov 5, 2024
1 parent 1679020 commit 925c3b1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 36 deletions.
21 changes: 3 additions & 18 deletions rmw_zenoh_cpp/src/rmw_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
21 changes: 3 additions & 18 deletions rmw_zenoh_cpp/src/zenohd/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 925c3b1

Please sign in to comment.