Skip to content

Commit

Permalink
feat: rename zenoh::try_init_log_from_env to zenoh::init_logging
Browse files Browse the repository at this point in the history
  • Loading branch information
wyfo committed Jun 18, 2024
1 parent 338af96 commit 99dbc4c
Show file tree
Hide file tree
Showing 35 changed files with 66 additions and 62 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::try_init_log_from_env();
zenoh::init_logging();
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::try_init_log_from_env();
zenoh::init_logging();

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::try_init_log_from_env();
zenoh::init_logging();

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::try_init_log_from_env();
zenoh::init_logging();

let (config, selector, payload, 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::try_init_log_from_env();
zenoh::init_logging();

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 @@ -30,7 +30,7 @@ const N: usize = 10;
#[tokio::main]
async fn main() {
// initiate logging
zenoh::try_init_log_from_env();
zenoh::init_logging();

let (mut config, selector, mut payload, 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::try_init_log_from_env();
zenoh::init_logging();

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::try_init_log_from_env();
zenoh::init_logging();

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::try_init_log_from_env();
zenoh::init_logging();

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::try_init_log_from_env();
zenoh::init_logging();

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::try_init_log_from_env();
zenoh::init_logging();

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::try_init_log_from_env();
zenoh::init_logging();

let (config, key_expr, payload, 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 @@ -27,7 +27,7 @@ const N: usize = 10;
#[tokio::main]
async fn main() -> Result<(), ZError> {
// Initiate logging
zenoh::try_init_log_from_env();
zenoh::init_logging();

let (mut config, path, payload) = 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::try_init_log_from_env();
zenoh::init_logging();
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 @@ -20,7 +20,7 @@ use zenoh_examples::CommonArgs;

fn main() {
// initiate logging
zenoh::try_init_log_from_env();
zenoh::init_logging();
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::try_init_log_from_env();
zenoh::init_logging();

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::try_init_log_from_env();
zenoh::init_logging();

let (config, key_expr, payload) = 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::try_init_log_from_env();
zenoh::init_logging();

let (config, key_expr, payload) = 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::try_init_log_from_env();
zenoh::init_logging();

let (mut config, key_expr, payload, 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::try_init_log_from_env();
zenoh::init_logging();

let (mut config, key_expr, payload, 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::try_init_log_from_env();
zenoh::init_logging();

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::try_init_log_from_env();
zenoh::init_logging();

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::try_init_log_from_env();
zenoh::init_logging();

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::try_init_log_from_env();
zenoh::init_logging();

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::try_init_log_from_env();
zenoh::init_logging();

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::try_init_log_from_env();
zenoh::init_logging();

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

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

#[doc(inline)]
pub use {
crate::{
config::Config,
core::{Error, Result},
scouting::scout,
session::{open, Session},
},
zenoh_util::{init_log_from_env_or, try_init_log_from_env},
pub use zenoh_util::{
init_log_from_env_or as init_logging_with, try_init_log_from_env as init_logging,
};

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

pub mod prelude;
Expand Down Expand Up @@ -403,6 +405,8 @@ pub mod internal {
};
}

pub use zenoh_util::init_log_with_callback;

pub use crate::api::value::Value;
}

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::try_init_log_from_env();
zenoh::init_logging();
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::try_init_log_from_env();
zenoh::init_logging();
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::try_init_log_from_env();
zenoh::init_logging();
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::try_init_log_from_env();
zenoh::init_logging();

let mut config = Config::default();
config
Expand Down
6 changes: 3 additions & 3 deletions zenoh/tests/matching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async fn create_session_pair(locator: &str) -> (Session, Session) {

#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
async fn zenoh_matching_status_any() -> ZResult<()> {
zenoh_util::try_init_log_from_env();
zenoh_util::init_logging();
let (session1, session2) = create_session_pair("tcp/127.0.0.1:18001").await;

let publisher1 = ztimeout!(session1
Expand Down Expand Up @@ -92,7 +92,7 @@ async fn zenoh_matching_status_any() -> ZResult<()> {

#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
async fn zenoh_matching_status_remote() -> ZResult<()> {
zenoh_util::try_init_log_from_env();
zenoh_util::init_logging();

let session1 = ztimeout!(zenoh::open(config::peer())).unwrap();
let session2 = ztimeout!(zenoh::open(config::peer())).unwrap();
Expand Down Expand Up @@ -147,7 +147,7 @@ async fn zenoh_matching_status_remote() -> ZResult<()> {

#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
async fn zenoh_matching_status_local() -> ZResult<()> {
zenoh_util::try_init_log_from_env();
zenoh_util::init_logging();

let session1 = ztimeout!(zenoh::open(zenoh::config::peer())).unwrap();
let session2 = ztimeout!(zenoh::open(zenoh::config::peer())).unwrap();
Expand Down
Loading

0 comments on commit 99dbc4c

Please sign in to comment.