Skip to content

Commit

Permalink
feat: fully rework logging initialization
Browse files Browse the repository at this point in the history
Tests are now using `test-log` library.
See detailed `zenoh_util::init_logging` documentation.
  • Loading branch information
wyfo committed Jun 20, 2024
1 parent 4a314a6 commit cae04c3
Show file tree
Hide file tree
Showing 57 changed files with 2,734 additions and 2,751 deletions.
75 changes: 64 additions & 11 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ shellexpand = "3.0.0"
socket2 = { version = "0.5.1", features = ["all"] }
stop-token = "0.7.0"
syn = "2.0"
test-log = "0.2.16"
tide = "0.16.0"
token-cell = { version = "1.4.2", default-features = false }
tokio = { version = "1.35.1", default-features = false } # Default features are disabled due to some crates' requirements
Expand Down
1 change: 0 additions & 1 deletion ci/valgrind-check/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ tracing-subscriber = { version = "0.3", features = ["json", "env-filter"] }
futures = "0.3.25"
zenoh = { path = "../../zenoh/" }
zenoh-runtime = { path = "../../commons/zenoh-runtime/" }
zenoh-util = { path = "../../commons/zenoh-util/", features = ["test"] }

[[bin]]
name = "pub_sub"
Expand Down
2 changes: 1 addition & 1 deletion ci/valgrind-check/src/pub_sub/bin/z_pub_sub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use zenoh::{config::Config, key_expr::KeyExpr, prelude::*};
#[tokio::main]
async fn main() {
let _z = zenoh_runtime::ZRuntimePoolGuard;
zenoh_util::init_log_test();
zenoh::init_logging();

let pub_key_expr = KeyExpr::try_from("test/valgrind/data").unwrap();
let sub_key_expr = KeyExpr::try_from("test/valgrind/**").unwrap();
Expand Down
2 changes: 1 addition & 1 deletion ci/valgrind-check/src/queryable_get/bin/z_queryable_get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use zenoh::{
#[tokio::main]
async fn main() {
let _z = zenoh_runtime::ZRuntimePoolGuard;
zenoh_util::init_log_test();
zenoh::init_logging();

let queryable_key_expr = KeyExpr::try_from("test/valgrind/data").unwrap();
let get_selector = Selector::try_from("test/valgrind/**").unwrap();
Expand Down
1 change: 1 addition & 0 deletions commons/zenoh-buffers/src/zbuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,7 @@ impl ZBuf {
}
}

#[cfg(test)]
mod tests {
#[test]
fn zbuf_eq() {
Expand Down
26 changes: 13 additions & 13 deletions commons/zenoh-codec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ version = { workspace = true }
repository = { workspace = true }
homepage = { workspace = true }
authors = [
"kydos <[email protected]>",
"Luca Cominardi <[email protected]>",
"Pierre Avital <[email protected]>",
"kydos <[email protected]>",
"Luca Cominardi <[email protected]>",
"Pierre Avital <[email protected]>",
]
edition = { workspace = true }
license = { workspace = true }
Expand All @@ -31,20 +31,20 @@ description = "Internal crate for zenoh."
[features]
default = ["std"]
std = [
"tracing",
"serde/std",
"uhlc/std",
"zenoh-protocol/std"
"tracing",
"serde/std",
"uhlc/std",
"zenoh-protocol/std"
]
shared-memory = [
"std",
"zenoh-shm",
"zenoh-protocol/shared-memory",
"zenoh-buffers/shared-memory"
"std",
"zenoh-shm",
"zenoh-protocol/shared-memory",
"zenoh-buffers/shared-memory"
]

[dependencies]
tracing = {workspace = true, optional = true }
tracing = { workspace = true, optional = true }
serde = { workspace = true, features = ["alloc"] }
uhlc = { workspace = true }
zenoh-buffers = { workspace = true, default-features = false }
Expand All @@ -54,10 +54,10 @@ zenoh-shm = { workspace = true, optional = true }
# INFO: May cause problems when testing no_std stuff. Check this tool: https://docs.rs/crate/cargo-no-dev-deps/0.1.0
[dev-dependencies]
criterion = { workspace = true }
test-log = { workspace = true }

rand = { workspace = true, features = ["default"] }
zenoh-protocol = { workspace = true, features = ["test"] }
zenoh-util = {workspace = true }

[[bench]]
name = "codec"
Expand Down
1 change: 1 addition & 0 deletions commons/zenoh-codec/src/core/zint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ zint_impl!(usize);
// }
// }

// #[cfg(test)]
// mod tests {
// #[test]
// fn u64_overhead() {
Expand Down
4 changes: 1 addition & 3 deletions commons/zenoh-codec/tests/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,8 @@ fn codec_shm_info() {
}

// Common
#[test]
#[test_log::test]
fn codec_extension() {
zenoh_util::try_init_log_from_env();

macro_rules! run_extension_single {
($ext:ty, $buff:expr) => {
let codec = Zenoh080::new();
Expand Down
1 change: 1 addition & 0 deletions commons/zenoh-crypto/src/cipher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ impl BlockCipher {
}
}

#[cfg(test)]
mod tests {
#[test]
fn cipher() {
Expand Down
8 changes: 4 additions & 4 deletions commons/zenoh-shm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ version = { workspace = true }
repository = { workspace = true }
homepage = { workspace = true }
authors = [
"kydos <[email protected]>",
"Luca Cominardi <[email protected]>",
"Pierre Avital <[email protected]>",
"kydos <[email protected]>",
"Luca Cominardi <[email protected]>",
"Pierre Avital <[email protected]>",
]
edition = { workspace = true }
license = { workspace = true }
Expand All @@ -35,7 +35,7 @@ test = ["num_cpus"]
async-trait = { workspace = true }
bincode = { workspace = true }
crc = { workspace = true }
tracing = {workspace = true}
tracing = { workspace = true }
serde = { workspace = true, features = ["default"] }
shared_memory = { workspace = true }
tokio = { workspace = true }
Expand Down
3 changes: 0 additions & 3 deletions commons/zenoh-util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ description = "Internal crate for zenoh."
[badges]
maintenance = { status = "actively-developed" }

[features]
test = []

[dependencies]
async-std = { workspace = true, features = ["default", "unstable"] }
tokio = { workspace = true, features = ["time", "net"] }
Expand Down
Loading

0 comments on commit cae04c3

Please sign in to comment.