From e6864931cccfc9c504b4bbc3ae7899334e70fdae Mon Sep 17 00:00:00 2001 From: Julien Enoch Date: Mon, 3 Jun 2024 19:26:36 +0200 Subject: [PATCH 1/3] Fix `zid_to_str` to treat `z_id_t` as little endian (#190) * Fix zid_to_str (a zid is little endian) * Fix code style --- rmw_zenoh_cpp/src/detail/liveliness_utils.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rmw_zenoh_cpp/src/detail/liveliness_utils.cpp b/rmw_zenoh_cpp/src/detail/liveliness_utils.cpp index 78d5b412..c7d073e8 100644 --- a/rmw_zenoh_cpp/src/detail/liveliness_utils.cpp +++ b/rmw_zenoh_cpp/src/detail/liveliness_utils.cpp @@ -223,8 +223,9 @@ std::string zid_to_str(const z_id_t & id) { std::stringstream ss; ss << std::hex; - size_t i = 0; - for (; i < (sizeof(id.id)); i++) { + // By Zenoh convention a z_id_t is a little endian u128 + size_t i = sizeof(id.id) - 1; + for (; i >= 0; i--) { ss << static_cast(id.id[i]); } return ss.str(); From 4efb835491bc358dfc67e76d65ff70ca69b23f8f Mon Sep 17 00:00:00 2001 From: Yadu Date: Tue, 4 Jun 2024 11:06:28 -0700 Subject: [PATCH 2/3] Fix regression from #190 (#195) * Fix UB Signed-off-by: Yadunund * Rework logic Signed-off-by: Yadunund --------- Signed-off-by: Yadunund --- rmw_zenoh_cpp/src/detail/liveliness_utils.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rmw_zenoh_cpp/src/detail/liveliness_utils.cpp b/rmw_zenoh_cpp/src/detail/liveliness_utils.cpp index c7d073e8..1b6a3098 100644 --- a/rmw_zenoh_cpp/src/detail/liveliness_utils.cpp +++ b/rmw_zenoh_cpp/src/detail/liveliness_utils.cpp @@ -223,10 +223,10 @@ std::string zid_to_str(const z_id_t & id) { std::stringstream ss; ss << std::hex; - // By Zenoh convention a z_id_t is a little endian u128 - size_t i = sizeof(id.id) - 1; - for (; i >= 0; i--) { - ss << static_cast(id.id[i]); + for (std::size_t i = 0; i < sizeof(id.id); i++) { + // By Zenoh convention a z_id_t is a little endian u128. + const std::size_t le_idx = sizeof(id.id) - 1 - i; + ss << static_cast(id.id[le_idx]); } return ss.str(); } From 66ec842030fda0cd381835f8ed2577f331fb5729 Mon Sep 17 00:00:00 2001 From: Julien Enoch Date: Tue, 4 Jun 2024 20:17:24 +0200 Subject: [PATCH 3/3] README.md: add Logging section (#191) * README.md: add Logging section * nit Signed-off-by: Yadunund --------- Signed-off-by: Yadunund Co-authored-by: Yadunund --- README.md | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index fb958e9b..9a4097eb 100644 --- a/README.md +++ b/README.md @@ -38,14 +38,14 @@ cd ~/ws_rmw_zenoh source install/setup.bash ``` -### Start the zenoh router -> Note: Manually launching zenoh router won't be necessary in the future. +### Start the Zenoh router +> Note: Manually launching Zenoh router won't be necessary in the future. ```bash # terminal 1 ros2 run rmw_zenoh_cpp rmw_zenohd ``` -> Note: Without the zenoh router, nodes will not be able to discover each other since multicast discovery is disabled by default in the node's session config. Instead, nodes will receive discovery information about other peers via the zenoh router's gossip functionality. See more information on the session configs [below](#config). +> Note: Without the Zenoh router, nodes will not be able to discover each other since multicast discovery is disabled by default in the node's session config. Instead, nodes will receive discovery information about other peers via the Zenoh router's gossip functionality. See more information on the session configs [below](#config). ### Terminate ROS 2 daemon started with another RMW ```bash @@ -119,3 +119,15 @@ In this example, the `Zenoh router` will connect to the `Zenoh router` running o ``` > Note: To connect multiple hosts, include the endpoints of all `Zenoh routers` in the network. + +### Logging + +The core of Zenoh is implemented in Rust and uses a logging library that can be configured via a `RUST_LOG` environment variable. +This variable can be configured independently for each Node and the Zenoh router. +For instance: +- `RUST_LOG=zenoh=info` activates information logs about Zenoh initialization and the endpoints it's listening on. +- `RUST_LOG=zenoh=info,zenoh_transport=debug` adds some debug logs about the connectivity events in Zenoh. +- `RUST_LOG=zenoh=info,zenoh::net::routing::queries=trace` adds some trace logs for each query (i.e. calls to services and actions). +- `RUST_LOG=zenoh=debug` activates all the debug logs. + +For more information on the `RUST_LOG` syntax, see https://docs.rs/env_logger/latest/env_logger/#enabling-logging.