Skip to content

Commit

Permalink
enable logging for examples and add doc for logging (#199)
Browse files Browse the repository at this point in the history
  • Loading branch information
keepsimple1 committed Apr 21, 2024
1 parent 020df6e commit 544c544
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions examples/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
use mdns_sd::{ServiceDaemon, ServiceEvent};

fn main() {
env_logger::init();

// Create a daemon
let mdns = ServiceDaemon::new().expect("Failed to create daemon");

Expand Down
2 changes: 2 additions & 0 deletions examples/register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ use mdns_sd::{DaemonEvent, ServiceDaemon, ServiceInfo};
use std::{env, thread, time::Duration};

fn main() {
env_logger::init();

// Simple command line options.
let args: Vec<String> = env::args().collect();
let mut should_unreg = false;
Expand Down
18 changes: 18 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,24 @@
//! We focus on the common use cases at first, and currently have the following limitations:
//! - Only support multicast, not unicast send/recv.
//! - Only support 32-bit or bigger platforms, not 16-bit platforms.
//!
//! # Use logging in tests and examples
//!
//! Often times it is helpful to enable logging running tests or examples to examine the details.
//! For tests and examples, we use [`env_logger`](https://docs.rs/env_logger/latest/env_logger/)
//! as the logger and use [`test-log`](https://docs.rs/test-log/latest/test_log/) to enable logging for tests.
//! For instance you can show all test logs using:
//!
//! ```shell
//! RUST_LOG=debug cargo test integration_success -- --nocapture
//! ```
//!
//! We also enabled the logging for the examples. For instance you can do:
//!
//! ```shell
//! RUST_LOG=debug cargo run --example query _printer._tcp
//! ```
//!

#![forbid(unsafe_code)]
#![allow(clippy::single_component_path_imports)]
Expand Down

0 comments on commit 544c544

Please sign in to comment.