Skip to content

Commit

Permalink
Merge pull request #1083 from ZettaScaleLabs/zenoh_init_log
Browse files Browse the repository at this point in the history
feat: expose `zenoh::try_init_log_from_env` from `zenoh_util`
  • Loading branch information
milyin authored Jun 4, 2024
2 parents ec687ca + a1c0581 commit 8932d37
Show file tree
Hide file tree
Showing 38 changed files with 64 additions and 61 deletions.
2 changes: 1 addition & 1 deletion examples/examples/z_alloc_shm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use zenoh::{
#[tokio::main]
async fn main() {
// Initiate logging
zenoh_util::try_init_log_from_env();
zenoh::try_init_log_from_env();
run().await.unwrap()
}

Expand Down
2 changes: 1 addition & 1 deletion examples/examples/z_delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use zenoh_examples::CommonArgs;
#[tokio::main]
async fn main() {
// initiate logging
zenoh_util::try_init_log_from_env();
zenoh::try_init_log_from_env();

let (config, key_expr) = parse_args();

Expand Down
2 changes: 1 addition & 1 deletion examples/examples/z_forward.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use zenoh_ext::SubscriberForward;
#[tokio::main]
async fn main() {
// Initiate logging
zenoh_util::try_init_log_from_env();
zenoh::try_init_log_from_env();

let (config, key_expr, forward) = parse_args();

Expand Down
2 changes: 1 addition & 1 deletion examples/examples/z_get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use zenoh_examples::CommonArgs;
#[tokio::main]
async fn main() {
// initiate logging
zenoh_util::try_init_log_from_env();
zenoh::try_init_log_from_env();

let (config, selector, value, target, timeout) = parse_args();

Expand Down
2 changes: 1 addition & 1 deletion examples/examples/z_get_liveliness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use zenoh_examples::CommonArgs;
#[tokio::main]
async fn main() {
// initiate logging
zenoh_util::try_init_log_from_env();
zenoh::try_init_log_from_env();

let (config, key_expr, timeout) = parse_args();

Expand Down
2 changes: 1 addition & 1 deletion examples/examples/z_get_shm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const N: usize = 10;
#[tokio::main]
async fn main() {
// initiate logging
zenoh_util::try_init_log_from_env();
zenoh::try_init_log_from_env();

let (mut config, selector, mut value, target, timeout) = parse_args();

Expand Down
2 changes: 1 addition & 1 deletion examples/examples/z_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use zenoh_examples::CommonArgs;
#[tokio::main]
async fn main() {
// initiate logging
zenoh_util::try_init_log_from_env();
zenoh::try_init_log_from_env();

let config = parse_args();

Expand Down
2 changes: 1 addition & 1 deletion examples/examples/z_liveliness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use zenoh_examples::CommonArgs;
#[tokio::main]
async fn main() {
// Initiate logging
zenoh_util::try_init_log_from_env();
zenoh::try_init_log_from_env();

let (config, key_expr) = parse_args();

Expand Down
2 changes: 1 addition & 1 deletion examples/examples/z_ping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use zenoh_examples::CommonArgs;

fn main() {
// initiate logging
zenoh_util::try_init_log_from_env();
zenoh::try_init_log_from_env();

let (config, warmup, size, n, express) = parse_args();
let session = zenoh::open(config).wait().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion examples/examples/z_ping_shm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use zenoh_examples::CommonArgs;

fn main() {
// Initiate logging
zenoh_util::try_init_log_from_env();
zenoh::try_init_log_from_env();

let (mut config, warmup, size, n) = parse_args();

Expand Down
2 changes: 1 addition & 1 deletion examples/examples/z_pong.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use zenoh_examples::CommonArgs;

fn main() {
// initiate logging
zenoh_util::try_init_log_from_env();
zenoh::try_init_log_from_env();

let (mut config, express) = parse_args();

Expand Down
2 changes: 1 addition & 1 deletion examples/examples/z_pub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use zenoh_examples::CommonArgs;
#[tokio::main]
async fn main() {
// Initiate logging
zenoh_util::try_init_log_from_env();
zenoh::try_init_log_from_env();

let (config, key_expr, value, attachment) = parse_args();

Expand Down
2 changes: 1 addition & 1 deletion examples/examples/z_pub_shm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const N: usize = 10;
#[tokio::main]
async fn main() -> Result<(), ZError> {
// Initiate logging
zenoh_util::try_init_log_from_env();
zenoh::try_init_log_from_env();

let (mut config, path, value) = parse_args();

Expand Down
2 changes: 1 addition & 1 deletion examples/examples/z_pub_shm_thr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use zenoh_examples::CommonArgs;
#[tokio::main]
async fn main() {
// initiate logging
zenoh_util::try_init_log_from_env();
zenoh::try_init_log_from_env();
let (mut config, sm_size, size) = parse_args();

// A probing procedure for shared memory is performed upon session opening. To enable `z_pub_shm_thr` to operate
Expand Down
2 changes: 1 addition & 1 deletion examples/examples/z_pub_thr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use zenoh_examples::CommonArgs;

fn main() {
// initiate logging
zenoh_util::try_init_log_from_env();
zenoh::try_init_log_from_env();
let args = Args::parse();

let mut prio = Priority::DEFAULT;
Expand Down
2 changes: 1 addition & 1 deletion examples/examples/z_pull.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use zenoh_examples::CommonArgs;
#[tokio::main]
async fn main() {
// initiate logging
zenoh_util::try_init_log_from_env();
zenoh::try_init_log_from_env();

let (config, key_expr, size, interval) = parse_args();

Expand Down
2 changes: 1 addition & 1 deletion examples/examples/z_put.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use zenoh_examples::CommonArgs;
#[tokio::main]
async fn main() {
// initiate logging
zenoh_util::try_init_log_from_env();
zenoh::try_init_log_from_env();

let (config, key_expr, value) = parse_args();

Expand Down
2 changes: 1 addition & 1 deletion examples/examples/z_put_float.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use zenoh_examples::CommonArgs;
#[tokio::main]
async fn main() {
// initiate logging
zenoh_util::try_init_log_from_env();
zenoh::try_init_log_from_env();

let (config, key_expr, value) = parse_args();

Expand Down
2 changes: 1 addition & 1 deletion examples/examples/z_queryable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use zenoh_examples::CommonArgs;
#[tokio::main]
async fn main() {
// initiate logging
zenoh_util::try_init_log_from_env();
zenoh::try_init_log_from_env();

let (mut config, key_expr, value, complete) = parse_args();

Expand Down
2 changes: 1 addition & 1 deletion examples/examples/z_queryable_shm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const N: usize = 10;
#[tokio::main]
async fn main() {
// initiate logging
zenoh_util::try_init_log_from_env();
zenoh::try_init_log_from_env();

let (mut config, key_expr, value, complete) = parse_args();

Expand Down
2 changes: 1 addition & 1 deletion examples/examples/z_scout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use zenoh::{config::WhatAmI, scout, Config};
#[tokio::main]
async fn main() {
// initiate logging
zenoh_util::try_init_log_from_env();
zenoh::try_init_log_from_env();

println!("Scouting...");
let receiver = scout(WhatAmI::Peer | WhatAmI::Router, Config::default())
Expand Down
2 changes: 1 addition & 1 deletion examples/examples/z_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use zenoh_examples::CommonArgs;
#[tokio::main]
async fn main() {
// initiate logging
zenoh_util::try_init_log_from_env();
zenoh::try_init_log_from_env();

let (config, key_expr, complete) = parse_args();

Expand Down
2 changes: 1 addition & 1 deletion examples/examples/z_sub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use zenoh_examples::CommonArgs;
#[tokio::main]
async fn main() {
// Initiate logging
zenoh_util::try_init_log_from_env();
zenoh::try_init_log_from_env();

let (mut config, key_expr) = parse_args();

Expand Down
2 changes: 1 addition & 1 deletion examples/examples/z_sub_liveliness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use zenoh_examples::CommonArgs;
#[tokio::main]
async fn main() {
// Initiate logging
zenoh_util::try_init_log_from_env();
zenoh::try_init_log_from_env();

let (config, key_expr) = parse_args();

Expand Down
2 changes: 1 addition & 1 deletion examples/examples/z_sub_shm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use zenoh_examples::CommonArgs;
#[tokio::main]
async fn main() {
// Initiate logging
zenoh_util::try_init_log_from_env();
zenoh::try_init_log_from_env();

let (mut config, key_expr) = parse_args();

Expand Down
2 changes: 1 addition & 1 deletion examples/examples/z_sub_thr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl Drop for Stats {

fn main() {
// initiate logging
zenoh_util::try_init_log_from_env();
zenoh::try_init_log_from_env();

let (mut config, m, n) = parse_args();

Expand Down
2 changes: 1 addition & 1 deletion zenoh-ext/examples/examples/z_member.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use zenoh_ext::group::*;

#[tokio::main]
async fn main() {
zenoh_util::try_init_log_from_env();
zenoh::try_init_log_from_env();
let z = Arc::new(zenoh::open(Config::default()).await.unwrap());
let member = Member::new(z.zid().to_string())
.unwrap()
Expand Down
2 changes: 1 addition & 1 deletion zenoh-ext/examples/examples/z_pub_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use zenoh_ext_examples::CommonArgs;
#[tokio::main]
async fn main() {
// Initiate logging
zenoh_util::try_init_log_from_env();
zenoh::try_init_log_from_env();

let (config, key_expr, value, history, prefix, complete) = parse_args();

Expand Down
2 changes: 1 addition & 1 deletion zenoh-ext/examples/examples/z_query_sub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use zenoh_ext_examples::CommonArgs;
#[tokio::main]
async fn main() {
// Initiate logging
zenoh_util::try_init_log_from_env();
zenoh::try_init_log_from_env();

let (config, key_expr, query) = parse_args();

Expand Down
2 changes: 1 addition & 1 deletion zenoh-ext/examples/examples/z_view_size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use zenoh_ext_examples::CommonArgs;

#[tokio::main]
async fn main() {
zenoh_util::try_init_log_from_env();
zenoh::try_init_log_from_env();

let (config, group_name, id, size, timeout) = parse_args();

Expand Down
15 changes: 9 additions & 6 deletions zenoh/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,15 @@ pub const FEATURES: &str = zenoh_util::concat_enabled_features!(
);

#[doc(inline)]
pub use crate::{
config::Config,
core::{Error, Result},
key_expr::{kedefine, keformat, kewrite},
scouting::scout,
session::{open, Session},
pub use {
crate::{
config::Config,
core::{Error, Result},
key_expr::{kedefine, keformat, kewrite},
scouting::scout,
session::{open, Session},
},
zenoh_util::try_init_log_from_env,
};

pub mod prelude;
Expand Down
2 changes: 1 addition & 1 deletion zenoh/tests/acl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ mod test {

#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
async fn test_acl() {
zenoh_util::try_init_log_from_env();
zenoh::try_init_log_from_env();
test_pub_sub_deny().await;
test_pub_sub_allow().await;
test_pub_sub_deny_then_allow().await;
Expand Down
6 changes: 3 additions & 3 deletions zenoh/tests/interceptors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ fn downsampling_by_keyexpr_impl(flow: InterceptorFlow) {

#[test]
fn downsampling_by_keyexpr() {
zenoh_util::try_init_log_from_env();
zenoh::try_init_log_from_env();
downsampling_by_keyexpr_impl(InterceptorFlow::Ingress);
downsampling_by_keyexpr_impl(InterceptorFlow::Egress);
}
Expand Down Expand Up @@ -235,15 +235,15 @@ fn downsampling_by_interface_impl(flow: InterceptorFlow) {
#[cfg(unix)]
#[test]
fn downsampling_by_interface() {
zenoh_util::try_init_log_from_env();
zenoh::try_init_log_from_env();
downsampling_by_interface_impl(InterceptorFlow::Ingress);
downsampling_by_interface_impl(InterceptorFlow::Egress);
}

#[test]
#[should_panic(expected = "unknown variant `down`")]
fn downsampling_config_error_wrong_strategy() {
zenoh_util::try_init_log_from_env();
zenoh::try_init_log_from_env();

let mut config = Config::default();
config
Expand Down
Loading

0 comments on commit 8932d37

Please sign in to comment.