Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tracing): using tracing and zenoh-util init_log #308

Merged
merged 5 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 1 addition & 26 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,18 @@ maintenance = { status = "actively-developed" }
async-std = "=1.12.0"
async-trait = "0.1.66"
chrono = "0.4.34"
env_logger = "0.10.0"
futures = "0.3.26"
json5 = "0.4.1"
lazy_static = "1.4.0"
libc = "0.2.139"
log = "0.4.17"
rand = "0.8.5"
spin = "0.9.5"
# shared-memory enabled for zenoh even if zenoh-c "shared-memory" feature is disabled. This is to make "std::mem::transmute" work for `ZSLice`
zenoh = { version = "0.11.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main", features = ["shared-memory", "unstable"], default-features = false }
zenoh-protocol = { version = "0.11.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main", features = ["shared-memory"] }
zenoh-util = { version = "0.11.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main" }
zenoh-ext = { version = "0.11.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main", features = ["unstable"] }
tracing = "0.1"

[build-dependencies]
cbindgen = "0.24.3"
Expand Down
3 changes: 1 addition & 2 deletions Cargo.toml.in
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,18 @@ maintenance = { status = "actively-developed" }
async-std = "=1.12.0"
async-trait = "0.1.66"
chrono = "0.4.34"
env_logger = "0.10.0"
futures = "0.3.26"
json5 = "0.4.1"
lazy_static = "1.4.0"
libc = "0.2.139"
log = "0.4.17"
rand = "0.8.5"
spin = "0.9.5"
# shared-memory enabled for zenoh even if zenoh-c "shared-memory" feature is disabled. This is to make "std::mem::transmute" work for `ZSLice`
zenoh = { version = "0.11.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main", features = ["shared-memory", "unstable"], default-features = false }
zenoh-protocol = { version = "0.11.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main", features = ["shared-memory"] }
zenoh-util = { version = "0.11.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main" }
zenoh-ext = { version = "0.11.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main", features = ["unstable"] }
tracing = "0.1"

[build-dependencies]
cbindgen = "0.24.3"
Expand Down
2 changes: 1 addition & 1 deletion src/attachment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub extern "C" fn z_attachment_iterate(
if let Some(driver) = this.iteration_driver {
return driver(this.data, body, context);
}
log::error!("Invalid iteration_driver");
tracing::error!("Invalid iteration_driver");
i8::MIN
}

Expand Down
2 changes: 1 addition & 1 deletion src/closures/hello_closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub extern "C" fn z_closure_hello_call(
match closure.call {
Some(call) => call(hello, closure.context),
None => {
log::error!("Attempted to call an uninitialized closure!");
tracing::error!("Attempted to call an uninitialized closure!");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/closures/matching_status_closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub extern "C" fn zcu_closure_matching_status_call(
match closure.call {
Some(call) => call(sample, closure.context),
None => {
log::error!("Attempted to call an uninitialized closure!");
tracing::error!("Attempted to call an uninitialized closure!");
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/closures/query_channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub extern "C" fn zc_query_fifo_new(bound: usize) -> z_owned_query_channel_t {
From::from(move |query: &mut z_owned_query_t| {
if let Some(query) = query.take() {
if let Err(e) = tx.send(query) {
log::error!("Attempted to push onto a closed query_fifo: {}", e)
tracing::error!("Attempted to push onto a closed query_fifo: {}", e)
}
}
}),
Expand All @@ -69,7 +69,7 @@ pub extern "C" fn zc_query_fifo_new(bound: usize) -> z_owned_query_channel_t {
From::from(move |query: &mut z_owned_query_t| {
if let Some(query) = query.take() {
if let Err(e) = tx.send(query) {
log::error!("Attempted to push onto a closed query_fifo: {}", e)
tracing::error!("Attempted to push onto a closed query_fifo: {}", e)
}
}
}),
Expand Down Expand Up @@ -105,7 +105,7 @@ pub extern "C" fn zc_query_non_blocking_fifo_new(bound: usize) -> z_owned_query_
From::from(move |query: &mut z_owned_query_t| {
if let Some(query) = query.take() {
if let Err(e) = tx.send(query) {
log::error!("Attempted to push onto a closed query_fifo: {}", e)
tracing::error!("Attempted to push onto a closed query_fifo: {}", e)
}
}
}),
Expand All @@ -117,7 +117,7 @@ pub extern "C" fn zc_query_non_blocking_fifo_new(bound: usize) -> z_owned_query_
From::from(move |query: &mut z_owned_query_t| {
if let Some(query) = query.take() {
if let Err(e) = tx.send(query) {
log::error!("Attempted to push onto a closed query_fifo: {}", e)
tracing::error!("Attempted to push onto a closed query_fifo: {}", e)
}
}
}),
Expand Down Expand Up @@ -180,7 +180,7 @@ pub extern "C" fn z_query_channel_closure_call(
match closure.call {
Some(call) => call(sample, closure.context),
None => {
log::error!("Attempted to call an uninitialized closure!");
tracing::error!("Attempted to call an uninitialized closure!");
true
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/closures/query_closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub extern "C" fn z_closure_query_null() -> z_owned_closure_query_t {
pub extern "C" fn z_closure_query_call(closure: &z_owned_closure_query_t, query: &z_query_t) {
match closure.call {
Some(call) => call(query, closure.context),
None => log::error!("Attempted to call an uninitialized closure!"),
None => tracing::error!("Attempted to call an uninitialized closure!"),
}
}
/// Drops the closure. Droping an uninitialized closure is a no-op.
Expand Down Expand Up @@ -126,7 +126,7 @@ pub extern "C" fn z_closure_owned_query_call(
) {
match closure.call {
Some(call) => call(query, closure.context),
None => log::error!("Attempted to call an uninitialized closure!"),
None => tracing::error!("Attempted to call an uninitialized closure!"),
}
}
/// Drops the closure. Droping an uninitialized closure is a no-op.
Expand Down
2 changes: 1 addition & 1 deletion src/closures/reply_closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub extern "C" fn z_closure_reply_call(
match closure.call {
Some(call) => call(sample, closure.context),
None => {
log::error!("Attempted to call an uninitialized closure!");
tracing::error!("Attempted to call an uninitialized closure!");
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/closures/response_channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub extern "C" fn zc_reply_fifo_new(bound: usize) -> z_owned_reply_channel_t {
From::from(move |reply: &mut z_owned_reply_t| {
if let Some(reply) = reply.take() {
if let Err(e) = tx.send(reply) {
log::error!("Attempted to push onto a closed reply_fifo: {}", e)
tracing::error!("Attempted to push onto a closed reply_fifo: {}", e)
}
}
}),
Expand All @@ -68,7 +68,7 @@ pub extern "C" fn zc_reply_fifo_new(bound: usize) -> z_owned_reply_channel_t {
From::from(move |reply: &mut z_owned_reply_t| {
if let Some(reply) = reply.take() {
if let Err(e) = tx.send(reply) {
log::error!("Attempted to push onto a closed reply_fifo: {}", e)
tracing::error!("Attempted to push onto a closed reply_fifo: {}", e)
}
}
}),
Expand Down Expand Up @@ -104,7 +104,7 @@ pub extern "C" fn zc_reply_non_blocking_fifo_new(bound: usize) -> z_owned_reply_
From::from(move |reply: &mut z_owned_reply_t| {
if let Some(reply) = reply.take() {
if let Err(e) = tx.send(reply) {
log::error!("Attempted to push onto a closed reply_fifo: {}", e)
tracing::error!("Attempted to push onto a closed reply_fifo: {}", e)
}
}
}),
Expand All @@ -116,7 +116,7 @@ pub extern "C" fn zc_reply_non_blocking_fifo_new(bound: usize) -> z_owned_reply_
From::from(move |reply: &mut z_owned_reply_t| {
if let Some(reply) = reply.take() {
if let Err(e) = tx.send(reply) {
log::error!("Attempted to push onto a closed reply_fifo: {}", e)
tracing::error!("Attempted to push onto a closed reply_fifo: {}", e)
}
}
}),
Expand Down Expand Up @@ -180,7 +180,7 @@ pub extern "C" fn z_reply_channel_closure_call(
match closure.call {
Some(call) => call(sample, closure.context),
None => {
log::error!("Attempted to call an uninitialized closure!");
tracing::error!("Attempted to call an uninitialized closure!");
true
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/closures/sample_closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub extern "C" fn z_closure_sample_null() -> z_owned_closure_sample_t {
pub extern "C" fn z_closure_sample_call(closure: &z_owned_closure_sample_t, sample: &z_sample_t) {
match closure.call {
Some(call) => call(sample, closure.context),
None => log::error!("Attempted to call an uninitialized closure!"),
None => tracing::error!("Attempted to call an uninitialized closure!"),
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/closures/zenohid_closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub extern "C" fn z_closure_zid_call(closure: &z_owned_closure_zid_t, sample: &z
match closure.call {
Some(call) => call(sample, closure.context),
None => {
log::error!("Attempted to call an uninitialized closure!");
tracing::error!("Attempted to call an uninitialized closure!");
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,12 @@ pub unsafe extern "C" fn zc_config_from_file(path: *const c_char) -> z_owned_con
Ok(path) => match zenoh::config::Config::from_file(path) {
Ok(c) => Some(Box::new(c)),
Err(e) => {
log::error!("Couldn't read config from {}: {}", path, e);
tracing::error!("Couldn't read config from {}: {}", path, e);
None
}
},
Err(e) => {
log::error!("Invalid path '{}': {}", path_str.to_string_lossy(), e);
tracing::error!("Invalid path '{}': {}", path_str.to_string_lossy(), e);
None
}
}))
Expand Down Expand Up @@ -262,7 +262,7 @@ pub unsafe extern "C" fn z_config_client(
Vec::<zenoh::prelude::Locator>::new(),
|mut acc, it| match it {
Err(e) => {
log::error!("Error parsing peer address: {}", e);
tracing::error!("Error parsing peer address: {}", e);
Err(())
}
Ok(loc) => {
Expand Down
4 changes: 2 additions & 2 deletions src/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ pub unsafe extern "C" fn z_get(
CStr::from_ptr(parameters).to_str().unwrap()
};
let Some(s) = session.upgrade() else {
log::error!("{LOG_INVALID_SESSION}");
tracing::error!("{LOG_INVALID_SESSION}");
return i8::MIN;
};
let mut q = s.get(KeyExpr::try_from(keyexpr).unwrap().with_parameters(p));
Expand Down Expand Up @@ -244,7 +244,7 @@ pub unsafe extern "C" fn z_get(
{
Ok(()) => 0,
Err(e) => {
log::error!("{}", e);
tracing::error!("{}", e);
e.errno().get()
}
}
Expand Down