Skip to content

Commit

Permalink
Improve logging docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Mallets committed Sep 13, 2024
1 parent 4fd5c4d commit 3a13c09
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
8 changes: 5 additions & 3 deletions include/zenoh_commons.h
Original file line number Diff line number Diff line change
Expand Up @@ -4684,12 +4684,13 @@ z_result_t zc_config_to_string(const struct z_loaned_config_t *config,
* Initializes the zenoh runtime logger, using rust environment settings or the provided fallback level.
* E.g.: `RUST_LOG=info` will enable logging at info level. Similarly, you can set the variable to `error` or `debug`.
*
* Note that if the environment variable is not set, then fallback level will be used instead.
* Note that if the environment variable is not set, then fallback filter will be used instead.
* See https://docs.rs/env_logger/latest/env_logger/index.html for accepted filter format.
*
* @param level: The fallback level for logging if the environment variable is not set.
* @param level: The fallback filter if the `RUST_LOG` environment variable is not set. The format
*/
ZENOHC_API
z_result_t zc_init_log_from_env_or(const char *level);
z_result_t zc_init_log_from_env_or(const char *fallback);
/**
* Initializes the zenoh runtime logger with custom callback.
*
Expand Down Expand Up @@ -4990,6 +4991,7 @@ void zc_stop_z_runtime(void);
* E.g.: `RUST_LOG=info` will enable logging at info level. Similarly, you can set the variable to `error` or `debug`.
*
* Note that if the environment variable is not set, then logging will not be enabled.
* See https://docs.rs/env_logger/latest/env_logger/index.html for accepted filter format.
*/
ZENOHC_API
void zc_try_init_log_from_env(void);
Expand Down
12 changes: 8 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ pub mod shm;
/// E.g.: `RUST_LOG=info` will enable logging at info level. Similarly, you can set the variable to `error` or `debug`.
///
/// Note that if the environment variable is not set, then logging will not be enabled.
/// See https://docs.rs/env_logger/latest/env_logger/index.html for accepted filter format.
#[no_mangle]
pub extern "C" fn zc_try_init_log_from_env() {
zenoh::try_init_log_from_env();
Expand All @@ -89,13 +90,16 @@ pub extern "C" fn zc_try_init_log_from_env() {
/// Initializes the zenoh runtime logger, using rust environment settings or the provided fallback level.
/// E.g.: `RUST_LOG=info` will enable logging at info level. Similarly, you can set the variable to `error` or `debug`.
///
/// Note that if the environment variable is not set, then fallback level will be used instead.
/// Note that if the environment variable is not set, then fallback filter will be used instead.
/// See https://docs.rs/env_logger/latest/env_logger/index.html for accepted filter format.
///
/// @param level: The fallback level for logging if the environment variable is not set.
/// @param level: The fallback filter if the `RUST_LOG` environment variable is not set. The format
#[no_mangle]
#[allow(clippy::missing_safety_doc)]
pub unsafe extern "C" fn zc_init_log_from_env_or(level: *const libc::c_char) -> result::z_result_t {
match std::ffi::CStr::from_ptr(level).to_str() {
pub unsafe extern "C" fn zc_init_log_from_env_or(
fallback: *const libc::c_char,
) -> result::z_result_t {
match std::ffi::CStr::from_ptr(fallback).to_str() {
Ok(s) => {
zenoh::init_log_from_env_or(s);
result::Z_OK
Expand Down

0 comments on commit 3a13c09

Please sign in to comment.