Skip to content

Commit

Permalink
chore: replace log by tracing (#514)
Browse files Browse the repository at this point in the history
* chore: replace log by tracing

* fix: update Cargo.toml.in

* fix: remove useless dependencies

* fix: fix Cargo.toml.in
  • Loading branch information
wyfo authored Jul 15, 2024
1 parent 976da6a commit 896269d
Show file tree
Hide file tree
Showing 28 changed files with 73 additions and 103 deletions.
40 changes: 7 additions & 33 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 @@ -43,12 +43,11 @@ maintenance = { status = "actively-developed" }
async-std = "=1.12.0"
async-trait = "0.1.66"
chrono = "0.4.37"
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"
tracing = "0.1"
rand = "0.8.5"
spin = "0.9.5"
unwrap-infallible = "0.1.5"
Expand Down
7 changes: 2 additions & 5 deletions Cargo.toml.in
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ build = "@CARGO_PROJECT_DIR@build.rs"

[features]
logger-autoinit = []
shared-memory = ["zenoh/shared-memory", "zenoh-ext/shared-memory", "zenoh-protocol/shared-memory"]
shared-memory = ["zenoh/shared-memory", "zenoh-ext/shared-memory"]
unstable = ["zenoh/unstable", "zenoh-ext/unstable"]
default = ["zenoh/default"]

Expand All @@ -43,19 +43,16 @@ maintenance = { status = "actively-developed" }
async-std = "=1.12.0"
async-trait = "0.1.66"
chrono = "0.4.37"
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"
tracing = "0.1"
rand = "0.8.5"
spin = "0.9.5"
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 }
zenoh-protocol = { version = "0.11.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "dev/1.0.0" }
zenoh-util = { version = "0.11.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "dev/1.0.0" }
zenoh-ext = { version = "0.11.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "dev/1.0.0" }
flume = "*"

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 @@ -88,7 +88,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 @@ -97,7 +97,7 @@ pub extern "C" fn zcu_closure_matching_status_call(
match closure.call {
Some(call) => call(mathing_status, 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/query_closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub extern "C" fn z_closure_query_call(
let closure = closure.as_owned_c_type_ref();
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, resetting it to its gravestone state.
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 @@ -94,7 +94,7 @@ pub extern "C" fn z_closure_reply_call(
match closure.call {
Some(call) => call(reply, 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/sample_closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ pub extern "C" fn z_closure_sample_call(
let closure = closure.as_owned_c_type_ref();
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 @@ -89,7 +89,7 @@ pub extern "C" fn z_closure_zid_call(closure: &z_loaned_closure_zid_t, z_id: &z_
match closure.call {
Some(call) => call(z_id, 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/commons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ pub unsafe extern "C" fn z_encoding_from_substr(
errors::Z_OK
}
Err(e) => {
log::error!("Can not create encoding from non UTF-8 string: {}", e);
tracing::error!("Can not create encoding from non UTF-8 string: {}", e);
encoding.write(Encoding::default());
errors::Z_EINVAL
}
Expand Down
6 changes: 3 additions & 3 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,13 @@ pub unsafe extern "C" fn zc_config_from_file(
Ok(path) => match zenoh::config::Config::from_file(path) {
Ok(c) => Some(c),
Err(e) => {
log::error!("Couldn't read config from {}: {}", path, e);
tracing::error!("Couldn't read config from {}: {}", path, e);
res = errors::Z_EPARSE;
None
}
},
Err(e) => {
log::error!("Invalid path '{}': {}", path_str.to_string_lossy(), e);
tracing::error!("Invalid path '{}': {}", path_str.to_string_lossy(), e);
res = errors::Z_EIO;
None
}
Expand Down Expand Up @@ -324,7 +324,7 @@ pub unsafe extern "C" fn z_config_client(
.map(|&s| CStr::from_ptr(s).to_string_lossy().parse())
.try_fold(Vec::<Locator>::new(), |mut acc, it| match it {
Err(e) => {
log::error!("Error parsing peer address: {}", e);
tracing::error!("Error parsing peer address: {}", e);
res = errors::Z_EPARSE;
Err(())
}
Expand Down
2 changes: 1 addition & 1 deletion src/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ pub unsafe extern "C" fn z_get(
{
Ok(()) => errors::Z_OK,
Err(e) => {
log::error!("{}", e);
tracing::error!("{}", e);
errors::Z_EGENERIC
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/keyexpr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ unsafe fn keyexpr_create(
Ok(name) => match keyexpr_create_inner(name, should_auto_canonize, should_copy) {
Ok(v) => Ok(v),
Err(e) => {
log::error!("Couldn't construct a keyexpr: {}", e);
tracing::error!("Couldn't construct a keyexpr: {}", e);
Err(errors::Z_EINVAL)
}
},
Err(e) => {
log::error!("{}", e);
tracing::error!("{}", e);
Err(errors::Z_EPARSE)
}
}
Expand Down Expand Up @@ -473,7 +473,7 @@ pub extern "C" fn z_declare_keyexpr(
errors::Z_OK
}
Err(e) => {
log::debug!("{}", e);
tracing::debug!("{}", e);
this.write(None);
errors::Z_EGENERIC
}
Expand All @@ -489,14 +489,14 @@ pub extern "C" fn z_undeclare_keyexpr(
session: &z_loaned_session_t,
) -> errors::z_error_t {
let Some(kexpr) = this.as_rust_type_mut().take() else {
log::debug!("Attempted to undeclare dropped keyexpr");
tracing::debug!("Attempted to undeclare dropped keyexpr");
return errors::Z_EINVAL;
};
let session = session.as_rust_type_ref();
match session.undeclare(kexpr).wait() {
Ok(()) => errors::Z_OK,
Err(e) => {
log::debug!("{}", e);
tracing::debug!("{}", e);
errors::Z_EGENERIC
}
}
Expand Down Expand Up @@ -554,7 +554,7 @@ pub unsafe extern "C" fn z_keyexpr_concat(
let right = match std::str::from_utf8(right) {
Ok(r) => r,
Err(e) => {
log::error!(
tracing::error!(
"Couldn't concatenate {:02x?} to {} because it is not valid UTF8: {}",
right,
left,
Expand All @@ -570,7 +570,7 @@ pub unsafe extern "C" fn z_keyexpr_concat(
errors::Z_OK
}
Err(e) => {
log::error!("{}", e);
tracing::error!("{}", e);
this.write(None);
errors::Z_EGENERIC
}
Expand All @@ -594,7 +594,7 @@ pub extern "C" fn z_keyexpr_join(
errors::Z_OK
}
Err(e) => {
log::error!("{}", e);
tracing::error!("{}", e);
this.write(None);
errors::Z_EGENERIC
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub mod shm;
/// this will be performed automatically by `z_open` and `z_scout`.
#[no_mangle]
pub extern "C" fn zc_init_logger() {
let _ = env_logger::try_init();
zenoh::try_init_log_from_env();
}

// Test should be runned with `cargo test --no-default-features`
Expand Down
8 changes: 4 additions & 4 deletions src/liveliness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ pub extern "C" fn zc_liveliness_declare_token(
errors::Z_OK
}
Err(e) => {
log::error!("Failed to undeclare token: {e}");
tracing::error!("Failed to undeclare token: {e}");
this.write(None);
errors::Z_EGENERIC
}
Expand All @@ -115,7 +115,7 @@ pub extern "C" fn zc_liveliness_undeclare_token(
let this = this.as_rust_type_mut();
if let Some(token) = this.take() {
if let Err(e) = token.undeclare().wait() {
log::error!("Failed to undeclare token: {e}");
tracing::error!("Failed to undeclare token: {e}");
return errors::Z_EGENERIC;
}
}
Expand Down Expand Up @@ -171,7 +171,7 @@ pub extern "C" fn zc_liveliness_declare_subscriber(
errors::Z_OK
}
Err(e) => {
log::error!("Failed to subscribe to liveliness: {e}");
tracing::error!("Failed to subscribe to liveliness: {e}");
this.write(None);
errors::Z_EGENERIC
}
Expand Down Expand Up @@ -219,7 +219,7 @@ pub extern "C" fn zc_liveliness_get(
match builder.wait() {
Ok(()) => errors::Z_OK,
Err(e) => {
log::error!("Failed to subscribe to liveliness: {e}");
tracing::error!("Failed to subscribe to liveliness: {e}");
errors::Z_EGENERIC
}
}
Expand Down
Loading

0 comments on commit 896269d

Please # to comment.