diff --git a/Cargo.lock b/Cargo.lock index c6557bf0e..019cb2a50 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3683,6 +3683,7 @@ dependencies = [ "unwrap-infallible", "zenoh", "zenoh-ext", + "zenoh-util", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index ce05412b4..e794d8262 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -54,6 +54,7 @@ unwrap-infallible = "0.1.5" const_format = "0.2.32" zenoh = { version = "0.11.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "dev/1.0.0", default-features = false, features = ["internal"] } zenoh-ext = { version = "0.11.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "dev/1.0.0" , optional = true } +zenoh-util = { version = "0.11.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "dev/1.0.0" } flume = "*" [build-dependencies] diff --git a/Cargo.toml.in b/Cargo.toml.in index 34d98ecfd..42a2b0eb3 100644 --- a/Cargo.toml.in +++ b/Cargo.toml.in @@ -54,6 +54,7 @@ unwrap-infallible = "0.1.5" const_format = "0.2.32" zenoh = { version = "0.11.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "dev/1.0.0", default-features = false, features = ["internal"] } zenoh-ext = { version = "0.11.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "dev/1.0.0" , optional = true } +zenoh-util = { version = "0.11.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "dev/1.0.0" } flume = "*" [build-dependencies] diff --git a/README.md b/README.md index 7093c9436..5ff72b19a 100644 --- a/README.md +++ b/README.md @@ -213,7 +213,7 @@ Finally, we strongly advise that you refrain from using structure field that sta ## Logging -By default, zenoh-c enables Zenoh's logging library upon using the `z_open` or `z_scout` functions. This behavior can be disabled by adding `-DDISABLE_LOGGER_AUTOINIT:bool=true` to the `cmake` configuration command. The logger may then be manually re-enabled with the `zc_init_logger` function. +By default, zenoh-c enables Zenoh's logging library upon using the `z_open` or `z_scout` functions. This behavior can be disabled by adding `-DDISABLE_LOGGER_AUTOINIT:bool=true` to the `cmake` configuration command. The logger may then be manually re-enabled with the `zc_init_logging` function. ## Cross-Compilation diff --git a/build-resources/opaque-types/src/lib.rs b/build-resources/opaque-types/src/lib.rs index b0370ceef..1c1a8b7c6 100644 --- a/build-resources/opaque-types/src/lib.rs +++ b/build-resources/opaque-types/src/lib.rs @@ -63,7 +63,6 @@ pub struct CSlice { _context: *mut c_void, } - get_opaque_type_data!(CSlice, z_owned_slice_t); /// A contiguous sequence of bytes owned by some other entity. get_opaque_type_data!(CSlice, z_view_slice_t); diff --git a/docs/api.rst b/docs/api.rst index ddfe3e550..f39dc622b 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -877,3 +877,19 @@ Functions .. doxygenfunction:: ze_querying_subscriber_options_default .. doxygenfunction:: zc_reply_keyexpr_default + +Logging +======= + +Types +----- + +.. doxygenstruct:: zc_owned_closure_log_t +.. doxygenstruct:: zc_loaned_closure_log_t +.. doxygenenum:: zc_log_severity_t + +Functions +--------- + +.. doxygenfunction:: zc_init_logging +.. doxygenfunction:: zc_init_logging_with_callback diff --git a/include/zenoh_commons.h b/include/zenoh_commons.h index ae89b03b6..31a47cf2a 100644 --- a/include/zenoh_commons.h +++ b/include/zenoh_commons.h @@ -218,6 +218,41 @@ typedef enum zc_locality_t { ZC_LOCALITY_REMOTE = 2, } zc_locality_t; #endif +/** + * Severity level of Zenoh log message. + */ +typedef enum zc_log_severity_t { + /** + * The `trace` level. + * + * Designates very low priority, often extremely verbose, information. + */ + ZC_LOG_SEVERITY_TRACE = 0, + /** + * The "debug" level. + * + * Designates lower priority information. + */ + ZC_LOG_SEVERITY_DEBUG = 1, + /** + * The "info" level. + * + * Designates useful information. + */ + ZC_LOG_SEVERITY_INFO = 2, + /** + * The "warn" level. + * + * Designates hazardous situations. + */ + ZC_LOG_SEVERITY_WARN = 3, + /** + * The "error" level. + * + * Designates very serious errors. + */ + ZC_LOG_SEVERITY_ERROR = 4, +} zc_log_severity_t; /** * Key expressions types to which Queryable should reply to. */ @@ -337,6 +372,30 @@ typedef struct z_owned_closure_hello_t { */ void (*drop)(void *context); } z_owned_closure_hello_t; +/** + * A closure is a structure that contains all the elements for stateful, memory-leak-free callbacks: + * + * Closures are not guaranteed not to be called concurrently. + * + * It is guaranteed that: + * - `call` will never be called once `drop` has started. + * - `drop` will only be called **once**, and **after every** `call` has ended. + * - The two previous guarantees imply that `call` and `drop` are never called concurrently. + */ +typedef struct zc_owned_closure_log_t { + /** + * An optional pointer to a closure state. + */ + void *context; + /** + * A closure body. + */ + void (*call)(enum zc_log_severity_t severity, const struct z_loaned_string_t *msg, void *context); + /** + * An optional drop function that will be called when the closure is dropped. + */ + void (*drop)(void *context); +} zc_owned_closure_log_t; /** * A closure is a structure that contains all the elements for stateful, memory-leak-free callbacks: * @@ -1549,6 +1608,30 @@ ZENOHC_API void z_closure_hello_null(struct z_owned_closure_hello_t *this_); * Calls the closure. Calling an uninitialized closure is a no-op. */ ZENOHC_API +void z_closure_log_call(const struct zc_loaned_closure_log_t *closure, + enum zc_log_severity_t severity, + const struct z_loaned_string_t *msg); +/** + * Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. + */ +ZENOHC_API bool z_closure_log_check(const struct zc_owned_closure_log_t *this_); +/** + * Drops the closure. Droping an uninitialized closure is a no-op. + */ +ZENOHC_API void z_closure_log_drop(struct zc_owned_closure_log_t *closure); +/** + * Borrows closure. + */ +ZENOHC_API +const struct zc_loaned_closure_log_t *z_closure_log_loan(const struct zc_owned_closure_log_t *closure); +/** + * Constructs a closure in a gravestone state. + */ +ZENOHC_API void z_closure_log_null(struct zc_owned_closure_log_t *this_); +/** + * Calls the closure. Calling an uninitialized closure is a no-op. + */ +ZENOHC_API void z_closure_query_call(const struct z_loaned_closure_query_t *closure, const struct z_loaned_query_t *query); /** @@ -4304,12 +4387,22 @@ ZENOHC_API z_result_t zc_config_to_string(const struct z_loaned_config_t *config, struct z_owned_string_t *out_config_string); /** - * Initialises the zenoh runtime logger. + * Initializes the zenoh runtime logger, using rust environment settings. * * Note that unless you built zenoh-c with the `logger-autoinit` feature disabled, * this will be performed automatically by `z_open` and `z_scout`. */ -ZENOHC_API void zc_init_logger(void); +ZENOHC_API void zc_init_logging(void); +/** + * Initializes the zenoh runtime logger with custom callback. + * + * @param min_severity: Minimum severity level of log message to be be passed to the `callback`. + * Messages with lower severity levels will be ignored. + * @param callback: A closure that will be called with each log message severity level and content. + */ +ZENOHC_API +void zc_init_logging_with_callback(enum zc_log_severity_t min_severity, + struct zc_owned_closure_log_t *callback); /** * Constructs default value for `zc_liveliness_declaration_options_t`. */ diff --git a/include/zenoh_macros.h b/include/zenoh_macros.h index ce8463d69..01bb9c7be 100644 --- a/include/zenoh_macros.h +++ b/include/zenoh_macros.h @@ -9,6 +9,7 @@ z_owned_bytes_t : z_bytes_loan, \ z_owned_bytes_writer_t : z_bytes_writer_loan, \ z_owned_closure_hello_t : z_closure_hello_loan, \ + zc_owned_closure_log_t : z_closure_log_loan, \ z_owned_closure_query_t : z_closure_query_loan, \ z_owned_closure_reply_t : z_closure_reply_loan, \ z_owned_closure_sample_t : z_closure_sample_loan, \ @@ -56,6 +57,7 @@ z_owned_bytes_t* : z_bytes_drop, \ z_owned_bytes_writer_t* : z_bytes_writer_drop, \ z_owned_closure_hello_t* : z_closure_hello_drop, \ + zc_owned_closure_log_t* : z_closure_log_drop, \ z_owned_closure_query_t* : z_closure_query_drop, \ z_owned_closure_reply_t* : z_closure_reply_drop, \ z_owned_closure_sample_t* : z_closure_sample_drop, \ @@ -91,6 +93,7 @@ z_owned_bytes_t* : z_bytes_null, \ z_owned_bytes_writer_t* : z_bytes_writer_null, \ z_owned_closure_hello_t* : z_closure_hello_null, \ + zc_owned_closure_log_t* : z_closure_log_null, \ z_owned_closure_query_t* : z_closure_query_null, \ z_owned_closure_reply_t* : z_closure_reply_null, \ z_owned_closure_sample_t* : z_closure_sample_null, \ @@ -128,6 +131,7 @@ z_owned_bytes_t : z_bytes_check, \ z_owned_bytes_writer_t : z_bytes_writer_check, \ z_owned_closure_hello_t : z_closure_hello_check, \ + zc_owned_closure_log_t : z_closure_log_check, \ z_owned_closure_query_t : z_closure_query_check, \ z_owned_closure_reply_t : z_closure_reply_check, \ z_owned_closure_sample_t : z_closure_sample_check, \ @@ -197,6 +201,7 @@ inline const z_loaned_bytes_t* z_loan(const z_owned_bytes_t& this_) { return z_bytes_loan(&this_); }; inline const z_loaned_bytes_writer_t* z_loan(const z_owned_bytes_writer_t& this_) { return z_bytes_writer_loan(&this_); }; inline const z_loaned_closure_hello_t* z_loan(const z_owned_closure_hello_t& closure) { return z_closure_hello_loan(&closure); }; +inline const zc_loaned_closure_log_t* z_loan(const zc_owned_closure_log_t& closure) { return z_closure_log_loan(&closure); }; inline const z_loaned_closure_query_t* z_loan(const z_owned_closure_query_t& closure) { return z_closure_query_loan(&closure); }; inline const z_loaned_closure_reply_t* z_loan(const z_owned_closure_reply_t& closure) { return z_closure_reply_loan(&closure); }; inline const z_loaned_closure_sample_t* z_loan(const z_owned_closure_sample_t& closure) { return z_closure_sample_loan(&closure); }; @@ -240,6 +245,7 @@ inline z_loaned_string_array_t* z_loan_mut(z_owned_string_array_t& this_) { retu inline void z_drop(z_owned_bytes_t* this_) { return z_bytes_drop(this_); }; inline void z_drop(z_owned_bytes_writer_t* this_) { return z_bytes_writer_drop(this_); }; inline void z_drop(z_owned_closure_hello_t* closure) { return z_closure_hello_drop(closure); }; +inline void z_drop(zc_owned_closure_log_t* closure) { return z_closure_log_drop(closure); }; inline void z_drop(z_owned_closure_query_t* closure) { return z_closure_query_drop(closure); }; inline void z_drop(z_owned_closure_reply_t* closure) { return z_closure_reply_drop(closure); }; inline void z_drop(z_owned_closure_sample_t* closure) { return z_closure_sample_drop(closure); }; @@ -271,6 +277,7 @@ inline void z_drop(z_owned_subscriber_t* this_) { return z_subscriber_drop(this_ inline z_owned_bytes_t* z_move(z_owned_bytes_t& this_) { return (&this_); }; inline z_owned_bytes_writer_t* z_move(z_owned_bytes_writer_t& this_) { return (&this_); }; inline z_owned_closure_hello_t* z_move(z_owned_closure_hello_t& closure) { return (&closure); }; +inline zc_owned_closure_log_t* z_move(zc_owned_closure_log_t& closure) { return (&closure); }; inline z_owned_closure_query_t* z_move(z_owned_closure_query_t& closure) { return (&closure); }; inline z_owned_closure_reply_t* z_move(z_owned_closure_reply_t& closure) { return (&closure); }; inline z_owned_closure_sample_t* z_move(z_owned_closure_sample_t& closure) { return (&closure); }; @@ -302,6 +309,7 @@ inline z_owned_subscriber_t* z_move(z_owned_subscriber_t& this_) { return (&this inline void z_null(z_owned_bytes_t* this_) { return z_bytes_null(this_); }; inline void z_null(z_owned_bytes_writer_t* this_) { return z_bytes_writer_null(this_); }; inline void z_null(z_owned_closure_hello_t* this_) { return z_closure_hello_null(this_); }; +inline void z_null(zc_owned_closure_log_t* this_) { return z_closure_log_null(this_); }; inline void z_null(z_owned_closure_query_t* this_) { return z_closure_query_null(this_); }; inline void z_null(z_owned_closure_reply_t* this_) { return z_closure_reply_null(this_); }; inline void z_null(z_owned_closure_sample_t* this_) { return z_closure_sample_null(this_); }; @@ -337,6 +345,7 @@ inline void z_null(z_view_string_t* this_) { return z_view_string_null(this_); } inline bool z_check(const z_owned_bytes_t& this_) { return z_bytes_check(&this_); }; inline bool z_check(const z_owned_bytes_writer_t& this_) { return z_bytes_writer_check(&this_); }; inline bool z_check(const z_owned_closure_hello_t& this_) { return z_closure_hello_check(&this_); }; +inline bool z_check(const zc_owned_closure_log_t& this_) { return z_closure_log_check(&this_); }; inline bool z_check(const z_owned_closure_query_t& this_) { return z_closure_query_check(&this_); }; inline bool z_check(const z_owned_closure_reply_t& this_) { return z_closure_reply_check(&this_); }; inline bool z_check(const z_owned_closure_sample_t& this_) { return z_closure_sample_check(&this_); }; @@ -468,6 +477,8 @@ template<> struct z_loaned_to_owned_type_t { typedef z_ template<> struct z_owned_to_loaned_type_t { typedef z_loaned_bytes_writer_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_closure_hello_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_closure_hello_t type; }; +template<> struct z_loaned_to_owned_type_t { typedef zc_owned_closure_log_t type; }; +template<> struct z_owned_to_loaned_type_t { typedef zc_loaned_closure_log_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_closure_query_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_closure_query_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_closure_reply_t type; }; diff --git a/splitguide.yaml b/splitguide.yaml index a0edc71f2..913b422a8 100644 --- a/splitguide.yaml +++ b/splitguide.yaml @@ -67,6 +67,7 @@ zenoh_opaque.h: - z_loaned_closure_reply_t! - z_loaned_closure_sample_t! - z_loaned_closure_zid_t! + - zc_loaned_closure_log_t! - zc_loaned_closure_matching_status_t!#unstable - z_owned_shm_client_t!#shared-memory#unstable - zc_owned_shm_client_list_t!#shared-memory#unstable diff --git a/src/closures/log_closure.rs b/src/closures/log_closure.rs new file mode 100644 index 000000000..ff8dd0d13 --- /dev/null +++ b/src/closures/log_closure.rs @@ -0,0 +1,167 @@ +// +// Copyright (c) 2017, 2024 ZettaScale Technology. +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License 2.0 which is available at +// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 +// which is available at https://www.apache.org/licenses/LICENSE-2.0. +// +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// +// Contributors: +// ZettaScale Zenoh team, +// + +use std::mem::MaybeUninit; + +use crate::{ + transmute::{LoanedCTypeRef, OwnedCTypeRef}, + z_loaned_string_t, +}; + +#[repr(C)] +#[derive(PartialOrd, PartialEq)] +/// Severity level of Zenoh log message. +pub enum zc_log_severity_t { + /// The `trace` level. + /// + /// Designates very low priority, often extremely verbose, information. + TRACE = 0, + /// The "debug" level. + /// + /// Designates lower priority information. + DEBUG = 1, + /// The "info" level. + /// + /// Designates useful information. + INFO = 2, + /// The "warn" level. + /// + /// Designates hazardous situations. + WARN = 3, + /// The "error" level. + /// + /// Designates very serious errors. + ERROR = 4, +} + +impl From for tracing::Level { + fn from(value: zc_log_severity_t) -> Self { + match value { + zc_log_severity_t::TRACE => tracing::Level::TRACE, + zc_log_severity_t::DEBUG => tracing::Level::DEBUG, + zc_log_severity_t::INFO => tracing::Level::INFO, + zc_log_severity_t::WARN => tracing::Level::WARN, + zc_log_severity_t::ERROR => tracing::Level::ERROR, + } + } +} + +impl From for zc_log_severity_t { + fn from(value: tracing::Level) -> Self { + match value { + tracing::Level::TRACE => zc_log_severity_t::TRACE, + tracing::Level::DEBUG => zc_log_severity_t::DEBUG, + tracing::Level::INFO => zc_log_severity_t::INFO, + tracing::Level::WARN => zc_log_severity_t::WARN, + tracing::Level::ERROR => zc_log_severity_t::ERROR, + } + } +} + +/// A closure is a structure that contains all the elements for stateful, memory-leak-free callbacks: +/// +/// Closures are not guaranteed not to be called concurrently. +/// +/// It is guaranteed that: +/// - `call` will never be called once `drop` has started. +/// - `drop` will only be called **once**, and **after every** `call` has ended. +/// - The two previous guarantees imply that `call` and `drop` are never called concurrently. +#[repr(C)] +pub struct zc_owned_closure_log_t { + /// An optional pointer to a closure state. + context: *mut libc::c_void, + /// A closure body. + call: Option< + extern "C" fn( + severity: zc_log_severity_t, + msg: &z_loaned_string_t, + context: *mut libc::c_void, + ), + >, + /// An optional drop function that will be called when the closure is dropped. + drop: Option, +} + +/// Loaned closure. +#[repr(C)] +pub struct zc_loaned_closure_log_t { + _0: [usize; 3], +} + +decl_c_type!( + owned(zc_owned_closure_log_t), + loaned(zc_loaned_closure_log_t) +); + +impl zc_owned_closure_log_t { + pub fn empty() -> Self { + zc_owned_closure_log_t { + context: std::ptr::null_mut(), + call: None, + drop: None, + } + } + + pub fn is_empty(&self) -> bool { + self.call.is_none() && self.drop.is_none() && self.context.is_null() + } +} +unsafe impl Send for zc_owned_closure_log_t {} +unsafe impl Sync for zc_owned_closure_log_t {} +impl Drop for zc_owned_closure_log_t { + fn drop(&mut self) { + if let Some(drop) = self.drop { + drop(self.context) + } + } +} +/// Constructs a closure in a gravestone state. +#[no_mangle] +#[allow(clippy::missing_safety_doc)] +pub unsafe extern "C" fn z_closure_log_null(this: *mut MaybeUninit) { + (*this).write(zc_owned_closure_log_t::empty()); +} +/// Calls the closure. Calling an uninitialized closure is a no-op. +#[no_mangle] +pub extern "C" fn z_closure_log_call( + closure: &zc_loaned_closure_log_t, + severity: zc_log_severity_t, + msg: &z_loaned_string_t, +) { + let closure = closure.as_owned_c_type_ref(); + match closure.call { + Some(call) => call(severity, msg, closure.context), + None => { + tracing::error!("Attempted to call an uninitialized closure!"); + } + } +} +/// Drops the closure. Droping an uninitialized closure is a no-op. +#[no_mangle] +pub extern "C" fn z_closure_log_drop(closure: &mut zc_owned_closure_log_t) { + let mut empty_closure = zc_owned_closure_log_t::empty(); + std::mem::swap(&mut empty_closure, closure); +} + +/// Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. +#[no_mangle] +pub extern "C" fn z_closure_log_check(this: &zc_owned_closure_log_t) -> bool { + !this.is_empty() +} + +/// Borrows closure. +#[no_mangle] +pub extern "C" fn z_closure_log_loan(closure: &zc_owned_closure_log_t) -> &zc_loaned_closure_log_t { + closure.as_loaned_c_type_ref() +} diff --git a/src/closures/mod.rs b/src/closures/mod.rs index 7f3600dc4..56fcaad4d 100644 --- a/src/closures/mod.rs +++ b/src/closures/mod.rs @@ -37,6 +37,9 @@ mod sample_channel; pub use hello_closure::*; mod hello_closure; +pub use log_closure::*; +mod log_closure; + #[cfg(feature = "unstable")] pub use matching_status_closure::*; #[cfg(feature = "unstable")] diff --git a/src/lib.rs b/src/lib.rs index ab777dfa4..2a7633e19 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -18,6 +18,7 @@ use std::{cmp::min, slice}; use libc::c_void; +use crate::transmute::LoanedCTypeRef; #[macro_use] mod transmute; pub mod opaque_types; @@ -76,15 +77,42 @@ pub mod context; #[cfg(all(feature = "shared-memory", feature = "unstable"))] pub mod shm; -/// Initialises the zenoh runtime logger. +/// Initializes the zenoh runtime logger, using rust environment settings. /// /// Note that unless you built zenoh-c with the `logger-autoinit` feature disabled, /// this will be performed automatically by `z_open` and `z_scout`. #[no_mangle] -pub extern "C" fn zc_init_logger() { +pub extern "C" fn zc_init_logging() { zenoh::try_init_log_from_env(); } +/// Initializes the zenoh runtime logger with custom callback. +/// +/// @param min_severity: Minimum severity level of log message to be be passed to the `callback`. +/// Messages with lower severity levels will be ignored. +/// @param callback: A closure that will be called with each log message severity level and content. +#[no_mangle] +pub extern "C" fn zc_init_logging_with_callback( + min_severity: zc_log_severity_t, + callback: &mut zc_owned_closure_log_t, +) { + let mut closure = zc_owned_closure_log_t::empty(); + std::mem::swap(callback, &mut closure); + zenoh_util::log::init_log_with_callback( + move |meta| min_severity <= (*meta.level()).into(), + move |record| { + if let Some(s) = record.message.as_ref() { + let c = CStringView(CString(CSlice::new_borrowed_from_slice(s.as_bytes()))); + z_closure_log_call( + z_closure_log_loan(&closure), + record.level.into(), + c.as_loaned_c_type_ref(), + ); + } + }, + ); +} + // Test should be runned with `cargo test --no-default-features` #[test] #[cfg(not(feature = "default"))] diff --git a/src/scouting.rs b/src/scouting.rs index 7b7faec67..625f09ffb 100644 --- a/src/scouting.rs +++ b/src/scouting.rs @@ -24,7 +24,7 @@ use crate::{ result::{self, Z_OK}, transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit}, z_closure_hello_call, z_closure_hello_loan, z_owned_closure_hello_t, z_owned_config_t, - z_owned_string_array_t, z_view_string_t, zc_init_logger, CString, CStringView, ZVector, + z_owned_string_array_t, z_view_string_t, zc_init_logging, CString, CStringView, ZVector, }; #[cfg(feature = "unstable")] use crate::{transmute::IntoCType, z_id_t}; @@ -160,7 +160,7 @@ pub extern "C" fn z_scout( options: Option<&z_scout_options_t>, ) -> result::z_result_t { if cfg!(feature = "logger-autoinit") { - zc_init_logger(); + zc_init_logging(); } let options = options.cloned().unwrap_or_default(); let what = diff --git a/src/session.rs b/src/session.rs index 6fd268333..b891eed3d 100644 --- a/src/session.rs +++ b/src/session.rs @@ -22,7 +22,7 @@ use crate::{ opaque_types::{z_loaned_session_t, z_owned_session_t}, result, transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit}, - z_owned_config_t, zc_init_logger, + z_owned_config_t, zc_init_logging, }; decl_c_type!( owned(z_owned_session_t, Option>), @@ -57,7 +57,7 @@ pub extern "C" fn z_open( ) -> result::z_result_t { let this = this.as_rust_type_mut_uninit(); if cfg!(feature = "logger-autoinit") { - zc_init_logger(); + zc_init_logging(); } let Some(config) = config.as_rust_type_mut().take() else { tracing::error!("Config not provided"); @@ -90,7 +90,7 @@ pub extern "C" fn z_open_with_custom_shm_clients( ) -> result::z_result_t { let this = this.as_rust_type_mut_uninit(); if cfg!(feature = "logger-autoinit") { - zc_init_logger(); + zc_init_logging(); } let Some(config) = config.as_rust_type_mut().take() else { tracing::error!("Config not provided"); diff --git a/tests/z_api_alignment_test.c b/tests/z_api_alignment_test.c index 52a46c9b2..98276d794 100644 --- a/tests/z_api_alignment_test.c +++ b/tests/z_api_alignment_test.c @@ -107,7 +107,7 @@ int main(int argc, char **argv) { setbuf(stdout, NULL); #ifdef ZENOH_C - zc_init_logger(); + zc_init_logging(); #endif z_view_keyexpr_t key_demo_example, key_demo_example_a, key_demo_example_starstar; diff --git a/tests/z_api_config_test.c b/tests/z_api_config_test.c index 51f73c5ea..633a65de9 100644 --- a/tests/z_api_config_test.c +++ b/tests/z_api_config_test.c @@ -40,7 +40,7 @@ void config_peer() { } int main(int argc, char **argv) { - zc_init_logger(); + zc_init_logging(); config_client(); config_peer(); } diff --git a/tests/z_api_double_drop_test.c b/tests/z_api_double_drop_test.c index 5a6cc4ccb..089aff593 100644 --- a/tests/z_api_double_drop_test.c +++ b/tests/z_api_double_drop_test.c @@ -120,7 +120,7 @@ void test_queryable() { } int main(int argc, char **argv) { - zc_init_logger(); + zc_init_logging(); test_session(); test_publisher(); test_keyexpr(); diff --git a/tests/z_api_drop_options.c b/tests/z_api_drop_options.c index 099603f84..613dcfe6b 100644 --- a/tests/z_api_drop_options.c +++ b/tests/z_api_drop_options.c @@ -74,7 +74,7 @@ void get() { } int main(int argc, char **argv) { - zc_init_logger(); + zc_init_logging(); put(); get(); }